If you want to keep things moving in the bedroom, you should start by moving more at the gym or on the trail. Exercise, combined with healthier eating, may help overweight men avoid low testosterone through weight loss.

In a preliminary study presented by a meeting of endocrine professionals in Texas, researchers measured the effects of healthy lifestyle changes on the testosterone level of overweight, middle-aged men with prediabetes. In some men, low testosterone can result in reduced sex drive and poor erections, leading many to seek hormone replacement therapy to maintain their mojo.

Previous studies, however, have found that men with obesity or diabetes have a greater risk of low testosterone. This led researchers from Ireland to examine whether losing weight could reverse this decline in testosterone.

Researchers asked one group of men to make simple lifestyle changes. This included exercising 150 minutes a week, and eating less fat and fewer calories. Over the course of a year, these men lost an average of 17 pounds. Their shrinking weight and waist sizes were both linked to a 15 percent increase in their testosterone level. By the end of the study, only 11 percent of the men had low testosterone, down from 20 percent at the start.

The other men in the study, who received either a drug for type 2 diabetes or a placebo pill, didn’t see much improvement in their testosterone level after a year.

The study has not yet been published in a peer-reviewed journal, but losing weight has other well-documented benefits. The bottom line is that if you want to perform well in the bedroom and on the court, you need to eat healthy and exercise more.