As kingdoms and empires expanded, it became increasingly difficult for the rulers to maintain control over the more distant regions of their realm. To ensure that the far-flung cities of the empire contributed their expected share of duties and taxes to the government, local magistrates and courts were established. In the courthouse, the ruler's representatives listened to the grievances of the people and defined and enforced the laws that governed social interaction. This reduced crime, and thereby kept the local population productive.