New York is on the precipice of legalizing cannabis for recreational use.

Governor Andrew Cuomo and state lawmakers have reached an agreement on a plan to tax cannabis products and license dispensaries, Bloomberg reported on Wednesday. The agreement, the details of which are currently being finalized, clears the way for a vote that could come as early as next week. Once the measure passes, New York will become the 15th state to legalize cannabis for recreational use.

The agreements stipulates that a 13 percent sales tax would be imposed on cannabis sales, 9 percent of which would go to the state and 4 percent of which would go to localities. (Distributors would collect an additional excise tax of as much as 3 cents per milligram of THC.) The deal also holds for the creation of an Office of Cannabis Management, which would be responsible for distributing licenses.

Governor Cuomo’s office has estimated that a recreational cannabis program could bring in around $350 million a year once fully implemented. According to The Wall Street Journal, after funding the OCM and law-enforcement officers who are trained to recognize impaired driving, 20 percent of leftover revenue will go to treatment and public education, 40 percent will go to school aid, and 40 percent will go to a social equity fund. Recreational cannabis would be legal for adults 21 and older.

The agreement reached Wednesday comes after years of failed attempts in the state to legalize cannabis. The pressure to pass legislation increased as nearby states like Massachusetts and, most recently, New Jersey have passed measures to legalize recreational cannabis. “This year we have to get it done, and getting it done by the time the budget is passed is essential,” Cuomo said at an unrelated news conference earlier on Wednesday, adding that he and lawmakers were “a few inches” away from reaching an agreement. As it turns out, it was only a few hours.