 Tongwancheng fell in 427, forcing the Xia emperor Helian Chang to flee westward.He was captured nevertheless in 428 and his brother, Helian Ding, took over as the emperor of Xia.In fall 430, while Helian Ding was engaging the Western Qin, the Northern Wei made a surprise attack on the new Xia capital Pingliang and conquered the kingdom.