Marijuana, despite its historical connections to the environment-loving counterculture movement of the 1960s, can be an extremely environmentally-damaging plant. Research estimates that indoor cannabis cultivation accounts for 1% of all electricity use across the US; growing cannabis outdoors often involves high levels of pesticides; and marijuana needs so much water, the plants are draining rivers dry in California.

A potential environmentally friendly alternative comes in the unexpected form of yeast: Scientists have genetically engineered the microscopic fungi to create all the crucial psychoactive ingredients of marijuana. In a paper published today (Feb. 27) in Nature, biomolecular engineers from University of California-Berkeley showed that they’d engineered yeast molecules to create both THC (tetrahydrocannabinol, the main active ingredient of weed, which has been approved by the US Food and Drug Administration to treat nausea from cancer medications and to improve appetites in AIDS patients), and CBD (another marijuana cannabinoid, which has FDA approval to treat a rare form of epilepsy.)

The team took the genes responsible for THC and CBD out of cannabis and implanted them into the same brewer’s yeast, Saccharomyces cerevisiae, used to create bread and wine. “Once you’ve engineered it, you can grow out more of it,” says Jay Keasling, a Berkeley professor and co-author of the study. “The yeast is in our freezers and whenever we want to grow more, we take a sample, put it into sugar water with a few other nutrients. If you’ve got the right sugar in there, it will produce the cannabinoids.” (The “right sugar,” in this case, is galactose, as Keasling engineered the yeast to work with galactose sugar specifically.)

Genetically editing yeast to produce THC and CBD is cheaper than extracting the chemicals from cannabis plants. Keasling says he’ll be able to use his engineered yeast to create THC for less than $400 per kg, which is less than 1% of the cost of harvesting cannabis and extracting the THC. He’s already formed a company, Dimetrix, which holds the patent for THC- and CBD-producing yeast. Production costs are so low, he says, that the company should be able to make pure forms of THC and CBD more affordable to patients and consumers.

THC and CBD aren’t the only drug that can be produced by yeast: Brewer’s yeast can also be used to create insulin, and opioids such as codeine and morphine. And Keasling has experience in this area of bioengineering, having previously used yeast to create an anti-malarial drug, which led to a significant reduction in the cost of the drug.

The yeast can also be used to produce other cannabinoids that occur in cannabis, but which haven’t been studied to date as they only naturally exist in marijuana in such small doses that it’s too expensive to study their effects. And it’s possible to add chemicals to the yeast to create new, altered cannabinoids, which could potentially be used and studied for further effects. It turns out the humble yeast, long credited with giving us both bread and alcohol, is something of a drug-making machine.