The risk of overdosing on methadone is influenced by a person’s genetic makeup, a new study suggests.

Methadone is used to treat pain or addiction to opioids. It can be deadly if it remains in the body for too long, according to HealthDay.

Researchers from Washington University School of Medicine in St. Louis found a person’s genetic makeup influences how an enzyme in the liver metabolizes methadone. “This explains why some people can have very high levels of methadone in their blood — high enough to trigger a potential overdose — even if they have received the same dose of the drug as others who are not affected the same way,” lead researcher Dr. Evan Kharasch said in a university news release.

The study pinpointed genetic subtypes that affect the metabolism of methadone in the body, the article notes. The researchers said if genetic testing is used before patients are prescribed methadone, some of the 5,000 deaths due to methadone overdoses that occur annually in the U.S. could be prevented.

The researchers found blacks were more likely than whites to have higher methadone levels in the blood, even though they received equal amounts of the drug. Blacks were also more likely to have the genetic variation associated with slower methadone metabolism, and less likely to have the variation linked with faster methadone metabolism.

“We think that may explain why African-Americans and Caucasian patients typically clear methadone at different rates,” Kharasch said.

Genetic variations were more likely to affect methadone in liquid or pill form, compared with intravenous methadone.

The study appears in the journal Anesthesiology.