Everyone has heard marijuana described as a “gateway drug” to harder substances, but a new study suggests it could actually help people overcome serious addictions.

A team from the University of British Columbia has found using pot can potentially aid some people who are struggling with alcohol or even opioid addiction kick their habit.

“Research suggests that people may be using cannabis as an exit drug to reduce use of substances that are potentially more harmful,” lead investigator Zach Walsh, associate psychology professor at UBC’s Okanagan campus, said in a statement.

Walsh’s team performed a review that the university described as one of the most comprehensive on the topic of marijuana to date, going over all existing studies on medical cannabis and mental health, plus reviews of non-medical pot use.

Apart from marijuana’s potential application as an “exit drug,” they found it could help with symptoms of depression, post-traumatic stress disorder, and social anxiety.

Their review determined people suffering from bipolar disorder and psychosis should stay away from the drug, however.

Walsh said the study is important given that the drug could be legalized in Canada as early as next year.

“There is currently not a lot of clear guidance on how mental health professionals can best work with people who are using cannabis for medical purposes,” Walsh said. “With the end of prohibition, telling people to simply stop using may no longer be as feasible an option, so knowing how to consider cannabis in the treatment equation will become a necessity.”

The team’s research has been published in the Clinical Psychology Review journal.