Formula to not repeat the sin again
Say Astaghfirullah
100 times, Feeling ashamed
Say: لا حول ولا قوة إلا بالله
100 times, Ask Allah for strength to leave the sin
اللهم ألهمني رشدي وأعذني من شر نفسي
say 100 times
Thinking that you’re really asking Allah for hidayah
Protection from the evilness of the nafs