However, after the foundation of the city in the 7th century, the second wave of Jewish immigration arrived in the city, said to be coming from Cirenaica and Egypt.[3] With the settlement and growing prosperity of jews in the city as the Aghlabids slowly declined while the Fatimid Caliphate grew in power and extended its influence in North Africa through the Zirid dynasty, a need grew for contact with other jewish communities, apart from the other north african yeshivot in Fez, in Gabès, in Sijilmassa, and Tlemcen.[4] The religious leaders of Kairouan kept correspondence with communities from Spain, Provence, the Ashkenaz to Babylonia,[4] helped by its geographic location, including with leading Torah authorities such as Rav Sherira Gaon, Rav Hai Gaon, and Shmuel Hanaggid.