In the same year, Averroes was appointed qadi (judge) in Seville. In 1171 he became qadi in his hometown of Córdoba. As qadi he would decide cases and give fatwa s (legal opinions) based on religious law. The writing rate increased during this time despite other obligations and his travels within the Almohad empire. He also took the opportunity from his travels to conduct astronomical research. Many of his works produced between 1169 and 1179 were dated in Seville rather than Córdoba. In 1179 he was again appointed qadi in Seville. In 1182, he succeeded his friend Ibn Tufayl as court physician. Later the same year, he was appointed chief qadi of Córdoba, then controlled by the Taifa of Seville, a prestigious office that his grandfather had once held.