In 215, Cao Cao defeated Zhang Lu at the Battle of Yangping and seized Hanzhong Commandery. Sima Yi and Liu Ye advised him to take advantage of the victory to attack Yi Province, since it was still unstable under Liu Bei's new government and Liu Bei himself was away in Jing Province. Cao Cao, who was not fond of the terrain of the region, refused and left Xiahou Yuan, Zhang He and Xu Huang to defend Hanzhong Commandery.