The establishment of magnificent observatories, such as the one in Baghdad(829), and the influx of Greek astronomical texts, stimulated the interest of Arabic mathematicians in astronomy as well. Their accurate astronomical tables so necessary for orienting the mosques in the direction of Mecca.Khayyam was among those who made notable contributions to astronomy. About 1079, he was called on to adjust the Persian calendar in order that feasts and fasts might be kept at the proper times; the result was a remarkable work known as the Jalalian calendar, which is so accurate that it requires a day's correction every 5000 years. (our Gregorian calendar has an error of no more than one day in a span of 3330 years.) After his several accomplishments in scientific areas,Khayyam took up poetry and philosophy. His free thinking, so evident in the hedonistic patronage that had verses of the Rubiayat, led to charges of impiety. The court-sponsored patronage that had supported his observatory was withdrawn, and it had to be closed. Khayyam later undertook a pilgrimage to Mecca as a way of clearing himself of the accusation of atheism.