“We’re usually able to eliminate prostate cancer if it’s caught early,” says principle investigator Martin Sanda, M.D. Director of the Prostate Center at Beth Israel Deaconess Medical Center, in Boston. “Erectile dysfunction is well-recognized as a general concern, but the problem is that up to now, there really haven’t been guidelines available to help individualize the risk.”

How big is the risk? In a study of 2,940 men two years after treatment, 60 percent of patients who had their prostate removed reported a loss of sexual function. The numbers were lower, but still frightening, for external radiation (42 percent) and brachytherapy, or placing the radiation internally, near the prostate (37 percent).

The physical treatment is not the only danger. Stress and anxiety over the cancer and its treatment can cause ED in some men, as well.

So here’s some good news: new research is providing doctors the ability to personalize treatment and minimize erectile dysfunction—and pointing to several things you can do to keep Your High, Hard One.

Researchers found the odds of recovering sexual function were influenced by more than a course of treatment and age. Instead, they were able to look at those factors, plus BMI, the severity and size of the cancer, and, most importantly, the patient’s frequency of sexual activity when diagnosed, to determine the likelihood of ED.

So what can you do to avoid post-treatment E.D.?

Take your medicine. Researchers discovered nearly half of men hadn’t followed through on medication and other E.D. treatment after the cancer was treated. There’s room to improve post-treatment counseling, they found, but it ultimately falls to the patient to follow the recovery plan.

Watch your weight. Men who were more overweight were less likely to recover their erection, says Sanda. Is that enough incentive to lay off a second swing through the buffet line or that third beer? Thought so.