help!!!

I need help! So my husband (we will call him bob) we have dated before in the past. Well we broke up and I started dating another guy (we will call him john). Well me and john ended up pregnant, but I miscarried. Well john left me at the hospital by myself so i ended it him. Well bob was there for me, he made sure I was okay. Well me and bob get married. I love him with everything in me. But I just can't get john out of my head. It has killed mine and bobs sex life. But I can't help it. I still love john, but I love bob way more. I need help. Can someone please give me advice on how to stop thinking about john. I still see john every now and then because we live in a small town. And I only dated john for 4 months and I've been with bob for over 3 years on and off. SOMEONE HELP ME PLEASE.