The K-12 school in Deer Trail, Colorado, is in rot. The swimming pool is in such grave shape that students can’t use it anymore. People in wheelchairs have to be lifted up stairs. A sewage leak has closed the coach’s locker room. Even basic security is a problem, as the doors are so out of shape that they can be difficult to close and lock.

All of this, detailed in a report in the Denver Post, may soon come to an end. Thanks to an infusion of state cash, the small town is finally building a new school. And here’s the kicker: Some of the money funding the school is coming from Colorado’s excise tax for marijuana.

That’s right: Marijuana legalization is helping build new schools in Colorado.

It’s not just Deer Trail. As part of the state’s legalization plan, Colorado allocates $40 million in marijuana tax money into the state’s Building Excellent Schools Today (BEST) program every year. The money then goes to building new schools or improving them.

BEST is expected to fund nearly $300 million in school projects over the 2017-2018 fiscal year, of which about $40 million will come from the state’s marijuana excise tax.

The money has led even some people skeptical of legalization to accept some of its benefits. So far, not a single school district has rejected the funding.

“I don’t care where the money comes from. If we get a new school, I’m for it,” Hayley Whitehead, a Deer Trail graduate who works for the school district, told the Denver Post. “I see the invoices and see what we need for repairs, so I have a pretty good idea of the situation here.”

The $40 million for BEST is only part of what Colorado gets from marijuana each year. In 2016, the state raised an additional $117 million through the rest of its pot revenue, made up of marijuana license and application fees, sales taxes, and the excise tax. That other money was allocated to the Marijuana Tax Cash Fund, which is largely used for health care, education, drug treatment, drug prevention, and law enforcement programs; local governments; and a public school fund separate from BEST.

Marijuana legalization can’t solve every budget problem. In total, Colorado’s cannabis taxes and fees amount to less than 1 percent of the state’s budget. When it comes to schools in particular, the Denver Post reported that school projects alone will cost $18 billion through 2018 — far more than the entire BEST program provides.

But legalization still provides a lot of money — more than $150 million a year — that Colorado otherwise wouldn’t get. It won’t solve all of the state’s budget woes, but it does allow for extra spending on some projects that perhaps couldn’t be done before. For Colorado, that means a bit of help building newer, better schools.

For more on marijuana legalization, read Vox’s explainer.