the juntian system broke down. By the 8th century, the Tang had reverted to the centralized military system of the Han. However, this also did not last, and it broke down during the disorder of the An Lushan, which saw many fanzhen or local generals become extraordinarily powerful. These fanzhen were so powerful they collected taxes, raised armies, and made their positions hereditary. Because of this, the central army of the Tang was greatly weakened. Eventually, the Tang dynasty collapsed and the various fanzhen were made into separate kingdoms, a situation that would last until the Song dynasty. During the Tang, professional military writing and schools began to be set up to train officers, an institution that would be expanded during the Song. Tibetan tradition says that the Tang dynasty seized the Tibetan capital at Lhasa in 650. In 763 the Tibetans captured the Tang capital at Chang'an, for fifteen days during the An Shi Rebellion. In 756, over 4,000 Arab mercenaries joined the Chinese against An Lushan. They remained in China, and some of them were ancestors of the Hui people. During the Tang dynasty, 3,000 Chinese soldiers, and 3,000 Muslim soldiers were traded to each other in an agreement. Liao, Song and Jurchen Jin During the Song dynasty, the emperors were focused on curbing the power of the Fanzhen, local generals who they viewed as responsible for the collapse of the Tang dynasty. Local power was curbed and most power was centralized in the government, along with the army. In addition, the Song adopted a system in which commands by generals were ad hoc and temporary; this was to prevent the troops from becoming attached to their generals, who could potentially rebel. Successful generals such as Yue Fei and Liu Zen were persecuted by the Song Court who feared they would rebel. Although the system worked when it came to quelling rebellions, it was a failure in defending China and asserting its power. The Song had to rely on new gunpowder weapons introduced during the late Tang and bribes to fend off attacks by its enemies, such as the Liao (Khitans), West Xia (Tanguts), Jin (Jurchens), and Mongol Empire, as well as an expanded army of over 1 million men. The Song was greatly disadvantaged by the fact their neighbors had taken advantage of the era of chaos following the collapse of the Tang to advance into Northern