First you need to understand what kind of bad thoughts! Like this, even thinking about my ex is a bad thought for me :(
Anyways…I also get weird nasty thoughts that throw my mood off completely! Before this problem was more! Now using some techniques reduced!
1. You can search the subject in quora and read the problems and solutions of others on that subject.
2. Google your problems! (Solutions are available at WikiHow)
3. You can talk about this with a close friend. Their suggestions are very good!
4. You can challenge yourself! For example: If you think about such a thing, I am not a human race! I would be an inferior creature if I thought about it again! Who wants to tell themselves to think inferior!
5. If you believe in religion, then you can give your mind to religious work.. The mind becomes calm.


