During the next ten years he lived in poverty and taught for a living. He was later granted several important official posts during the Tang dynasty. Yan was promoted when Li Shimin  ascended the throne, but resumed his duty after his mother's funeral.
Over the following ten years, Yan struggled financially and taught for a living. Later, he received several prestigious government appointments during the Tang dynasty. When Li Shimin became emperor, Yan was promoted, but resumed his duties after his mother's funeral.