Complex sentence: When Master Dong retired, Yin took over as the supervisor of the security guards, working for the emperor in the Forbidden City.
Split into simpler sentences: When Master Dong retired, Yin took over as the supervisor of the security guards. Then he worked for the emperor in the Forbidden City.