As a teenager, he was greatly troubled by the Metaphysics of Aristotle, which he could not understand until he read al-Farabi's commentary on the work. For the next year and a half, he studied philosophy, in which he encountered greater obstacles. In such moments of baffled inquiry, he would leave his books, perform the requisite ablutions, then go to the mosque, and continue in prayer till light broke on his difficulties. Deep into the night, he would continue his studies, and even in his dreams problems would pursue him and work out their solution. Forty times, it is said, he read through the Metaphysics of Aristotle, till the words were imprinted on his memory; but their meaning was hopelessly obscure, until one day they found illumination, from the little commentary by Farabi, which he bought at a bookstall for the small sum of three dirhams. So great was his joy at the discovery, made with the help of a work from which he had expected only mystery, that he hastened to return thanks to God, and bestowed alms upon the poor.