The remedy for casting lustful glances and other sins is for a person to regularly study the biographies of the pious. Additionally, one should allocate some time to sit in solitude and ponder over the numerous warnings and punishments mentioned in the Qur’aan and Hadith for the sins that one is involved in. When the thought of sin crosses one’s mind, one should immediately remind oneself of these warnings and punishments. Through continuously doing this, insha Allah the strong urge of the nafs to commit sins will no longer remain. Thereafter, at times, if one perceives a slight inclination to commit sin, one should adopt self-resistance and oppose this inclination. However, if a person does not take courage and show determination then there is no remedy for such a person.
(Malfoozaat Hakeemul Ummat 23/57)