Stay Centrally Located
Rasul Allah (sal Allahu alaihi wasallam) said: “Allah has written for the son of Adam his inevitable share of adultery whether he is aware of it or not: The adultery of the eye is the looking (at something which is sinful to look at), and the adultery of the tongue is to utter (what it is unlawful to utter), and the inner self wishes and longs for (adultery) and the private parts turn that into reality or refrain from submitting to the temptation.” [Sahih Bukhari]
Immodesty, obscenity and any form of adutery be it of the eyes, ears, tongue or thoughts makes a hole in the heart. Through this hole leaks out eeman. So no matter how much you try to fill your heart with eeman, it will constantly flow out because of this hole. While an inappropriate thought might occur to anybody, as the Shaytaan is always trying to inspire people with these, yet it is the person who decieds whether to entertain such ideas, discussion, temptation or turn away from them.
If you are on a plateau, the more centrally you stand the safer you are. The more you get closer to the sides, the greater is the danger that you might fall off the edge. Therefore, to avoid the major form of adultery, the more we stay away from the minor forms of it, i.e. the adultery of the eyes, tongue, ears and thoughts, the safer we will be. Avoid movies that glamorize the immoral. Avoid hearing obscene talk. If an indecent thought occurs to you, seek refuge with Allah (subhana wa ta'ala) from the Shaytaan and don't entertain such thoughts.