Assalamo'alaykum Warahmatullah Wabarakatuh

What's the reference for this hadeeth which says when a person reaches his old age and is unable to perform some of the good acts that he would do in his youth,Allah commands the angels to write the rewards for all the good deeds that he was used to doing in his young age.
I hav'nt given the exact words of the hadeeth it's only the jist..

BarikAllahufeekum