After Yuwen Huaji reached Wei (魏縣, in modern Handan, Hebei), his close associate Zhang Kai (張愷), who had previously helped him suppress Sima's plot, plotted against him. Yuwen Huaji discovered the plot and executed Zhang and his co-conspirators, but by this point was growing increasingly despondent over the increasing desertions from his rank. He and his brothers often feasted and wept at the feast, and he and Yuwen Zhiji blamed each other for the plot. Yuwen Huaji, believing that defeat was near, wanted to take imperial title. In fall 618, he therefore poisoned Yang Hao to death and declared himself emperor of the state of Xu.