Former Qin fell into disarray in 383 following its defeat by Jin forces at the Battle of Fei River. In 386, Tuoba Gui, the grandson of Tuoba Shiyijian, the last King of Dai, took the opportunity to reestablish Dai and soon changed its name from Dai to Wei. Initially, Tuoba Gui was a vassal of Later Yan but claimed imperial title in 397 after defeating Murong Bao of Yan in Battle of Canhe Slope. Later, Tuoba Gui was given the title of Emperor Daowu of Northern Wei.