Hooking up with an ex

I keep stupidly having sex with my ex because I am desperate for physical affection and sex, but am nervous about having sex with a new person. He is the second person I've slept with but the first that sex has been enjoyable with. I know I could hookup with someone who would treat me much better, but I'm scared to let another person experience me sexually because it makes me feel vulnerable and insecure. I already know my ex knows about and accepts all of my flaws and don't know how to let someone else in to experience my flaws too. How do I get over this mindset so I can move on with my life?