Drinking in moderation isn’t necessarily a bad thing; some research, especially in the area of heart disease, suggests that alcohol may even provide some benefits.

But most studies on alcohol and health outcomes—like death from heart disease or cancer— have looked at drinking in isolation from other lifestyle factors. That’s a pretty artificial scenario, since a person’s drinking habits often go along with other lifestyle behaviors, such as diet, exercise and whether they smoke. Few studies have looked at how alcohol works in more real-world situations: how drinking affects people who exercise compared to those who aren’t as physically active, for example.

In their report published in the British Journal of Sports Medicine, Emmanuel Stamatakis, an associate professor at University of Sydney in Australia, and his colleagues looked specifically at the interaction between alcohol consumption and exercise to see how the behaviors affected each other when it came to mortality. They studied more than 36,000 middle-aged men and women for an average of nearly 10 years and tracked their death rates and causes of death.

Get our Health Newsletter. Sign up to receive the latest health and science news, plus answers to wellness questions and expert tips. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Not surprisingly, they found that drinking itself is linked to higher rates of early death from any cause, as well as death from cancer. And the more alcohol is consumed, the higher the risk of early death. But when Stamatakis layered in the amount of exercise people reported, he found that only those who weren’t physically active—meaning they did not meet the recommended 150 minutes of moderate-to-intense exercise a week—showed similar patterns of higher mortality. Among those who reported getting the recommended amounts of activity, their death rates were slightly lower as long as they drank with recommended guidelines (one to two drinks per day). People who drank beyond these amounts, at levels considered dangerous for their health, showed higher rates of death from any cause or cancer regardless of how much they exercised. The study found only a weak benefit in lowering deaths from heart-related issues among those who exercised.

“Among the physically active, there was no increase in cancer and all-cause mortality up to hazardous levels of alcohol consumption,” says Stamatakis. What’s more, there didn’t seem to be a difference in mortality rates among the physically active whether they exercise at the minimum recommended amount or whether they exercised more. “It looks like there is a kind of ceiling on the protective effect of physical activity,” he says.

But that doesn’t mean that you can drink with abandon and expect a few hours at the gym or a walking the dog to negate your indulging. Stamatakis notes that while his study found a potential protective effect on deaths from cancer if alcohol is considered together with exercise, drinking comes with a range of other health issues, some of which can impact mortality in other ways, including liver problems, domestic violence and depression. As tempting as it might be to think you can exercise away your night of drinking, it’s still best, says Stamatakis, to “stay within recommended limits and avoid binge drinking.”

Contact us at letters@time.com.