Well, when you get those thoughts, it doesn't mean you have to act on them. They are just ideas. You can control it by being rational in your own mind. If you get a thought and you say "wait, thats not like me" then you erase it. Dont let it control you. You control it.
I say everybody has two personalities in their head. One thinks good and the other thinks bad. Try not to let the bad control you. We all know right from wrong so remember that when that bad personality is trying to get you to do the wrong things think about the consequences about what might or can happen to you. Hopefully you get what I'm trying to say.