In ancient Egypt evidence of law enforcement exists as far back as the Old Kingdom period. There are records of an office known as "Judge Commandant of the Police" dating to the fourth dynasty. During the fifth dynasty at the end of the Old Kingdom period, officers armed with wooden sticks were tasked with guarding public places such as markets, temples, and parks, and apprehending criminals. They are known to have made use of trained monkeys, baboons, and dogs in guard duties and catching criminals. After the Old Kingdom collapsed, ushering in the First Intermediate Period, it is thought that the same model applied. During this period, Bedouins were hired to guard the borders and protect trade caravans. During the Middle Kingdom period, a professional police force was created with a specific focus on enforcing the law, as opposed to the previous informal arrangement of using warriors as police. The police force was further reformed during the New Kingdom period. Police officers served as interrogators, prosecutors, and court bailiffs, and were responsible for administering punishments handed down by judges. In addition, there were special units of police officers trained as priests who were responsible for guarding temples and tombs and preventing inappropriate behavior at festivals or improper observation of religious rites during services. Other police units were tasked with guarding caravans, guarding border crossings, protecting royal necropolises, guarding slaves at work or during transport, patrolling the Nile River, and guarding administrative buildings. By the Eighteenth Dynasty of the New Kingdom period, an elite desert-ranger police force called the Medjay was used to protect valuable areas, especially areas of pharaonic interest like capital cities, royal cemeteries, and the borders of Egypt. Though they are best known for their protection of the royal palaces and tombs in Thebes and the surrounding areas, the Medjay were used throughout Upper and Lower Egypt. Each regional unit had its own captain. The police forces of ancient Egypt did not guard rural communities, which often took care of their own judicial problems by appealing to village elders, but many of them had a constable to enforce state laws.