Many years ago as a young adult, I had a problem with impure thoughts. So I made it a practice that whenever an impure thought would flit through my mind I would just squelch it dead. I put it immediately out of my head and refused to think about it.
I did that for several days. My dreams had a sudden change in nature. They became extremely erotic - almost physically painful. I would wake up turn over and get back to sleep only to have it happen again. After about a week of that, I realized that the dreams were far more powerful and horrible than the occasional impure thought. I also realized that if I did not recognize the thought while awake, my subconscience would beat me with it while asleep.
So, when an impure thought came to me while awake, I recognized it as an impure thought but I refused to dwell on it. Sometimes it would hang there and try to get my attention and I would respond with, “Yes, I see you there, but no, I’m not going to think about you.” The dreams stopped.