Just a little technique that can help you..
I remember, one day, I had been at church for a little activity. And a guy came up to the stand and he wanted to talk about sexual sin. He said he had known some guys who went to a therapist in the church asking for help on how to prevent these thoughts from coming into their heads. He said he had a technique where he would tell his patients that whenever they had an impure thought that they should say in their mind “stop,stop,stop” and after that they would think of a place where they can be calm. But if you don’t know where you are going to go in your mind afterwards, the thought might just continue to grow in your mind till you fall victim of sin. I find this to be extremely helpful in time where I am struggling to find help from others. And I hope it can do the same for you.