A gene linked to attention deficit/hyperactivity disorder (ADHD) and addiction might also help you live to be 100.

A study published in the Journal of Neuroscience found that a version of a gene coding for a receptor for the brain chemical dopamine was 66% more common among people who lived to be 90 or older than among a group of younger people who were otherwise similar. The variant leads to a weaker response to the neurotransmitter, lowering the activity of the dopamine system that is responsible for generating feelings of pleasure, desire and reward, as well as for regulating movement.

The study included over 1000 people aged 90 to 109 who lived in the Leisure World retirement community in Laguna Woods, California. They were part of a group of nearly 14,000 highly educated people of mostly European ancestry who were initially studied in 1981.

Not only did the researchers find that the variant was more common among the oldest participants, they also learned that these people were also more physically active than their counterparts who lacked this particular version of the receptor. Having a less effective pleasure-generating dopamine system, the researchers speculate, may cause people to seek greater stimulation, making them more vigorous in the search for greater arousal. Perhaps as a result, these participants were twice as likely to exercise when first surveyed in 1981— and they remained considerably more active than those without the variant when data was collected again in 2003. That, say the researchers, may be the key to their longevity.

When dopamine isn’t regulated properly, it can contribute to a dysfunctional pursuit of good feelings, such as occurs in addictions, or lead to a hyperactive state as in attention deficit/hyperactivity disorder (ADHD). These conditions are generally associated with an increased risk of early death, rather than longevity, but the latest study suggests that “risk” genes for certain problems in some environments may be beneficial in other situations. It’s not helpful to think of genes as “good” or “bad,” in other words, but instead to consider them as more dynamic.

The dopamine variant may be a good example. This gene has been connected to ADHD, which in turn is linked to a 50% increase in the risk of car accidents, for example, as well as similar increases in other risk-taking behaviors that can lead to accidental injury and early death. Studies have also correlated the variant to heightened promiscuity and infidelity, which carry a higher incidence of sexually-transmitted disease.

But if people with this genetic variant make it past the risky years of adolescence and early adulthood, then the positive benefits of being physically active throughout their lifetime may give them some extra years. People with ADHD, for example, are often unable to sit still, and the constant fidgeting and activity may end up having a net positive effect on their ability to avoid chronic diseases associated with being sedentary. Even thrill-seeking behavior often requires physical exertion, so those who survive the potentially dangerous activities of their youth may actually live longer than those who weren’t always in pursuit of the next high.

That theory seems to be supported by the study, since the analysis found that the gene variant increased longevity mainly in women. “This gender difference could reflect potentially negative (and often risky) behaviors associated with [the gene] earlier in life, such as ADHD and drug abuse, which have a significant male bias,” the authors write.

The authors also studied the dopamine variant in rats, and found that the lifespans of animals genetically modified to lack the particular variant were 7-10% shorter than those of normal rats. The reason may have had something to do with their physical activity: the “knockout” rats missing the genetic variant were also less active. And while normal rats live longer if they are provided with more companionship and an environment that offers more opportunity for learning and exploration, the knockout rats didn’t get any benefit from such enrichment.

That suggests that the dopamine variant also depends on some interaction with the environment in which it exists. Previous studies found that the boys who were abused and possessed the variant, for example, were more likely to have conduct disorders, while those with the genetic variant but not abused actually were at lower risk of having behavioral problems than those who didn’t have the variant at all.

Similar yin-yang effects have been seen with genes linked with depression that seem to provide an advantage in some environments, as well as genes linked with autism that appear to be correlate with mathematical and engineering talent. Which argues against selecting traits based purely on their most obvious benefits: most traits, and the genes that are behind them, seem to come in different flavors that confer both benefits and risks.