بسم الله الرحمن الرحيم
The Messenger of Allah ﷺ said:
اتَّقِ اللَّهِ حَيْثُمَا كُنْتَ وَأَتْبِعْ السَّيِّئَةَ الْحَسَنَةَ تَمْحُهَا وَخَالِقِ النَّاسَ بِخُلُقٍ حَسَنٍ
❝Fear Allah wherever you are. And follow up a bad deed with a good deed and it will wipe it out. And behave towards the people with good character.❞ 
Following up a bad deed with a good deed illustrates an important point: that even those with taqwah are not free from faults or immune from slipping. No one is perfect, but those who are from the people of taqwah, do not persist in sin and take immediate remedial recourse in proactively blotting out sin, and building a contiguous stack of hasanat (i.e. good deeds).
Ibn Rajab said in his valued work, ‘Lata’if al-Ma’arif’ about indicators of acceptance and rejection of deeds:
من عمل طاعة من الطاعات وفرغ منها فعلامة قبولها أن يصلها بطاعة أخرى، وعلامة ردها أن يعقب تلك الطاعة بمعصية
“Whoever does an act (of ibadah) from obedience (to Allah) and earnestly completes it, the sign of its acceptance is that he follows it up with another (act of obedience). And the sign of a rejected act (of ibadah) is that its obedience is followed up with sin.” 
Our understanding of sin should be mobilising and not debilitating. Too often, we respond to a sin by putting ourselves in a corner and overwhelming ourselves with guilt and regret only – this needs to be a catalyst to move forward in good deeds and no become dejected. Sins can’t be used as an excuse to lag behind, and absolutely must not stop us from swiftly partaking in all other types of qualitative goodness.
Ibn al-Qayyim said about the ease in which deeds can become corrupted and the need to ensure their integrity:
ومحبطات الأعمال ومفسداتها أكثر من أن تحصر وليس الشأن في العمل إنما الشأن في حفظ العمل مما يفسده ويحبطه
“And things that cancel out good deeds and spoils them are too many to enumerate. It is not the importance of deeds (that count), rather it is the importance of protecting one’s good deeds from whatever may corrupt them or cancel them out.” 
Our response to a sin should not be languid, but rather a race to enact something good in hope of erasing sin. Our attitude should be one of caution and of eternal hope that Allah will have Mercy on us as long as we keep struggling and pushing forward. As He ﷻ Said in Al-Zumar (53).
 Al-Tirmidhi, 1987
 Lata’if al-Ma’arif, (1/224)
 Al-Wâbil al-Sayyib, p.18