The health and wealth of society depends to a large extent on good management of resources, such as food and water, and efficient government. Many engineering solutions were devised by the
Abbasids to maintain and improve their agricultural systems and water resources, while medical advances helped to improve the health of the population. In Kairouan, for example, in 248 / 862, the Aghlabids built a series of water reservoirs designed mainly to collect rainwater from the nearby valleys. Their ingenuity lay in the fact that they devised the means to collect water, purify and store it, and then make it available to the inhabitants of the city, herdsmen of the area and caravans passing by: all free of charge.