sentences:  He ended the wars against the Southern Song dynasty, canceled the Treaty of Shaoxing free of obligation, reconciled with the Jin dynasty's former ally Western Xia, instituted internal reforms in his administration, eliminated corrupt and incompetent officials, and promoted military generals who resisted the Mongol invasion and recovered lost territories from the Mongols.However, the Mongol Empire had become a formidable power by then, and in 1227 it completely conquered Western Xia and concentrated its attacks on the Jin dynasty.In 1232, the Mongols inflicted a crushing defeat on Jin forces at the Battle of Sanfengshan (三峯山之戰) and destroyed the bulk of the Jin armed forces.