A new study has shown how cannabis could be an effective treatment option for both pain relief and insomnia, for those looking to avoid prescription and over the counter pain and sleep medications.

The study, published in the Journal of Psychoactive Drugs, which looked at 1,000 people taking legalized marijuana in an American state found that among the 65% of people taking cannabis for pain, 80% found it was very or extremely helpful.

This led to 82% of these people being able to reduce, or stop taking over the counter pain medications, and 88% being able to stop taking opioid painkillers.

74% of the 1,000 interviewees bought it to help them sleep; 84% of whom said the marijuana had helped them, and over 83% said that they had since reduced or stopped taking over-the-counter or prescription sleep aids.

“Approximately 20% of American adults suffer from chronic pain, and one in three adults do not get enough sleep,” says Gwen Wurm, MD, assistant professor of clinical pediatrics at the University of Miami Miller School of Medicine, in a release.

Traditional over the counter medications and painkillers can help, however they may have serious side effects. Opioids depress the respiratory system, meaning that overdoses may be fatal.

Sleeping pills can lead to dependence and can also cause grogginess the next day, interfering with people’s work and social lives.

As a consequence, some people are looking to marijuana to help with their symptoms.

To find out more about these users, Wurm and her colleagues used survey data from people who purchased cannabis from two retail stores in Colorado, where it is legal for both medical and recreational use—meaning any adult over 21 with a valid government ID may purchase product.

“In states where adult use of cannabis is legal, our research suggests that many individuals bypass the medical cannabis route (which requires registering with the state) and are instead opting for the privacy of a legal adult use dispensary,” says Wurm.

Although the survey was conducted among customers willing to participate—meaning the results may not reflect the overall population of dispensary customers—other national survey data, and data from medical patients at medical cannabis dispensaries, also demonstrate that people who use cannabis to treat symptoms both decrease and stop their use of prescription medications.

However, the researchers caution that more research is needed to understand the health benefits and side effects of cannabis.

“The challenge is that health providers are far behind in knowing which cannabis products work and which do not. Until there is more research into which cannabis products work for which symptoms, patients will do their own ‘trial and error’ experiments, getting advice from friends, social media and dispensary employees,” says Wurm.