The composer, however, was still ambitious and wishing for a better post, so in 1721 he accepted the invitation to work in Hamburg as Kantor of the Johanneum Lateinschule, and music director of the city's five largest churches. Soon after arrival, Telemann encountered some opposition from church officials who found his secular music and activities to be too much of a distraction for both Telemann himself and the townsfolk. The next year, when Johann Kuhnau died and the city of Leipzig was looking for a new Thomaskantor, Telemann applied for the job and was approved, yet declined after Hamburg authorities agreed to give him a suitable raise. After another candidate, Christoph Graupner, declined, the post went to Johann Sebastian Bach.