In 737, the Tang dynasty helped unify the tribes and create a new kingdom called the Nanzhao (南诏 "Southern Zhao"). In 738 the capital was established in Taihe (south of Dali). It was in the Erhai valley; the mountains made it easy to defend; and there was a lot of farmland.