Endometriosis and Masturbation

Hey ladies , so I’m having a slight problem. Almost over a month ago , I started getting endometriosis and I been on two medication. I’m not in a relationship and nor do i have a sex partner so I masturbate and a day or so I cramp and it hurts so bad 🙄 is there anyway to avoid it or tips👀😭