The compromising of the country's border areas by decades of Jurchen and Japanese depredations presented the new Chosŏn government with an immediate policy challenge. Having obtained legitimacy after investiture by China in 1401 and 1403, the Chosŏn court moved to secure its northern and southern border areas through a combination of diplomacy, naturalization of border peoples, and trade policies. With the borders secured, the court shifted to a policy of maintaining security by limiting access to and travel within the country. At the same time, the court regularized its foreign relations by implementing a hierarchy consisting of Ming China at the top and then Chosŏn, the Japanese, and the Jurchen, in that order. By the early fifteenth century, these policies had enabled Chosŏn to realize its objectives of border security and border control.