To avoid such struggles in the future, the Yongzheng Emperor designed a system by which the living emperor would choose his successor in advance and on merit, but would keep his choice secret until his deathbed. The name of the future emperor was sealed in a casket that was hidden behind a panel in the rafters of the Qianqing Palace inside the Forbidden City. As successor, the Yongzheng Emperor chose his fourth son Hongli (1711–1799), the Qianlong Emperor, who himself selected his 15th son Yongyan, the Jiaqing Emperor (r. 1796–1820). The latter chose his successor Minning (1782–1850), the Daoguang Emperor, in 1799, but only read his testament shortly before dying.