The timing of my Teshuba (repentance) determines the quality and credibility of my act.
This is what Maimonides writes in Hilkhot Teshuba 2: 1.“What is considered a perfect and complete repentance? When one is confronted with the same opportunity to repeat the original transgression, but now he does not do it because he has repented … however, when one does not repeat the original transgression, [ and refrains from sinning], because now fears that other people would find out [or for similar reasons] … his repentance is accepted, but this is not considered a complete repentance. “
To explain the ideal scenario of Teshuba, Maimonides brings the example of a man who was involved in an adulterous relationship and he later regrets. What would demonstrate that his repentance has been complete, is that when faced with a similar opportunity to repeat his mistake, he refrains from it, because he has reached a new moral conscience and understanding. In the case mentioned above, for example, because now he realizes that being carried away by his impulses will hurt him spiritually, will disconnect him from HaShem and will destroy his family.
However, if that man abstains from committing the same transgression, not because of a renewed belief or understanding but because now he fears being discovered. Or perhaps because he has already being caught, his Teshuba / repentance is accepted, says haRambam, but this kind of repentance is far from ideal. Why? Because this individual has changed his behavior, not because of a renewed understanding of what is right and what is wrong: he has repented because he fears being caught or because he has been caught.
A modern example: very often read in the news about a public official who was caught in an act of corruption. Say, stealing public funds. Many times these people, after being discovered, stand in front of the television cameras and publicly express repentance. They ask forgiveness for what they have done wrong and for defrauding the public’s trust. This is certainly a brave gesture of repentance. However, this act is questionable in terms of its absolute credibility. Why? Because the process of repentance and apology did not happenbefore being discovered, but as a result of being caught. It is very likely that what has driven this person to repent was NOT a new moral conscience, but the interest of a reduced conviction or a better sentence.
The act of “perfect” repentance would occur when, while this person continued in their public functions, and without any external pressure to continue with his crime, before being caught, he realizes his error by the call of his own conscience, and He understands that what he was doing was immoral.
In that scenario, Teshuba is credible and complete.