Ordinarily, if you’re in a good mood, most likely you wouldn’t do anything to sabotage your health. But, let’s say you’re depressed. Perhaps, depending on how badly you felt, you might not even care about your future. Similarly, according to recent findings, HIV-positive men who have sex with men (MSM) may engage in riskier sex when they suffer from black moods.

For the study, scientists asked 106 sexually active, HIV-positive MSM in New York City to complete a survey each week, for a six-week period, regarding their sexual behavior, depression and well-being. Researchers found that the men who felt happier during a particular week were more likely to have safe sex. Conversely, those who said they felt more depressed than usual during a given week were more likely to engage in risky sexual behaviors.

“We all have bad days and good days, and bad weeks and good weeks. That’s life,” says Patrick A. Wilson, PhD, an associate professor of sociomedical sciences at Columbia University’s Mailman School of Public Health, and lead study author. “But it turns out that how moods change can be a big factor in influencing condom use.”

Wilson and his research team couldn’t explain exactly how the men’s moods in each group led them to make either healthy or unhealthy choices. Most of the participants in the study group were poor, black and Latino men. Wilson suggests that the men who suffered from depression may have experienced severe social stresses, such as stigma, and might have gone through tough economic times.

When compared to these men’s more immediate needs—a stable job, housing and support networks—the risk of HIV transmission may be of low concern, Wilson says. But he adds that other factors are likely at play: “It boils down to coping—recognizing your emotions and how to respond when they change.”