After crunching the numbers from 145 studies including over 88,000 men who averaged 56 years old, the researchers determined that those with diabetes were more than three times as likely to have erectile dysfunction than healthy guys were. In fact, 59 percent of men with diabetes had ED.What’s more, men with diabetes tended to develop their erectile dysfunction 10 to 15 years earlier than those without the condition did, according to the study.

So how can high blood sugar sink you in the bedroom?

Diabetes can damage your blood vessels and your nerves—both of which are needed for healthy erectile functioning, says Sean Skeldon, M.D., who has previously researched ED and diabetes, but was not involved in this study.

Another important point: Erectile dysfunction is often considered a harbinger of heart disease. That’s because the blood vessel issues that cause ED—say, like plaque buildup—can also affect your heart, too. They just manifest first with problems in the bedroom, since your blood vessels in your penis are smaller than the ones that carry blood to your heart.

The good news, though, is that many of the risk factors for diabetes are under your control—meaning your penis and your heart could benefit from some prevention strategies. One easy one? Eat three servings of legumes a week. That can cut your risk of diabetes by 35 percent, possibly because their fibre can help prevent blood sugar spikes.