The Sui dynasty unified China in AD 581 after more than 400 years of disunity, yet it only lasted 38 years. Much was accomplished during this dynasty's short reign; a population census, reformation of the bloated regional administration system and consolidation of the southern regions. One of the Sui's most important legacies was building the Grand Canal, which linked Hangzhou in the south to Beijing in the north. The network of canals aided and enhanced economic and cultural exchange between the south and north and would greatly influence China's development. The downfall of the Sui dynasty came with several military excursions into Korea. These disastrous wars were prohibitively expensive and brought the dynasty to bankruptcy. Peasant rebellions erupted throughout the countryside and Li Yuan, a Sui government minister ended the Sui dynasty when he founded the Tang dynasty.