Thanking Allah Ta'ala for saving one from committing sins
Q: A person committed some mistake but alhmdullilah, Allah saved him from getting into a big mess. He thanked Allah but he gets thoughts that if he had avoided the mistake, things would have been different, etc. and dwells on his past. He always did some mistakes because of laziness or ignorance but Allah saved him. So, how should he thank Allah but not think of the mistake?