People often ask us how to avoid sexual thoughts and fantasies from plaguing them. Normally we refer them to this page of our FAQ section, but today I want to discuss another important facet as well. There is a common theme throughout Chassidic literature, that the more a person does through action and deed, then the more his mind and thoughts are changed as well.
The Parsha of Ekev starts with the words "Vehaya Ekev Tishma'un". Rashi writes that the word "Ekev" which means "heel", symbolizes Mitzvos of "lesser importance". The Beis Ahron of Karlin explains that this is refering to "Action", i.e. the physical act of the Mitzvos, which are of lesser importance than holy thoughts. It is important to point out that there is a difference between the "Ikar" (the main) and the "Chashuv" (the important). The "Ikar" of the Mitzvos is the Ma'aseh - the deed. But the "Chashuv" part of the Mitzva is the thought, that one is doing Hashem's will. Explains the Beis Ahron, "Vehaya Ekev Tishma'un". If you will do the Ekev - the lesser important, physical act of the Mitzvos, then "Tishma'un" - your mind will become uplifted as well and you will merit the "Chashuv" part of the Mitzvos too.
The same applies in the area of bad thoughts. The more a person "does" by not doing (as Chaza"l say, that one who sits and doesn't do an aveira is considered as if he did a mitzvah), then the clearer one's thoughts will become and the fantasies will be less intense and less often. Every time you turn away from looking at something bad and every time you say "no" to the addiction, you are changing your mind as well.
And this is one of the foundations of The 12 steps. As it is written in the books, that even when a new behavior seems insignificant, by believing in the importance of what we are doing, we start to see real changes in our thinking and behavior. Every little time we take "action" by saying "no" to the addiction, no matter how small and insignificant it seems to us, we are changing our thought patterns in the place where it really counts, in the "Chashuv" - the mind.