Masturbation is it ok during BR?

roma
I just want an advise. I am actually 2mos pregnant and my OB puts me on a strict Bedrest since I already had miscarriage .so me and my husband were told not to have sexual intercourse but im just curious if its ok to masturbate since its really hard not to think of sexual fantasies. I am really trying my best not to do it but how can i deal with this feeling. Any advise?