Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:39:35

That Allah may remove from them the worst of what they did and reward them their due for the best of what they used to do.  

so that God may absolve them of the worst of what they did, and pay them their reward by the best of what they used to do (aswa’a and ahsana mean ˹simply˺ al-sayyi’, ‘bad’, and al-hasan, ‘good’).
القرآن:٣٩:٣٥

لِيُكَفِّرَ اللَّهُ عَنْهُمْ أَسْوَأَ الَّذِي عَمِلُوا وَيَجْزِيَهُمْ أَجْرَهُمْ بِأَحْسَنِ الَّذِي كَانُوا يَعْمَلُونَ  

{ليكفّر الله عنهم أسوأ الذي عملوا ويجزيهم أجرهم بأحسن الذي كانوا يعملون} أسوأ وأحسن بمعنى السيء والحسن.