The Senate on Thursday voted to change the way millions of federal dollars designed to help educate poor children are divided among the states, a move that would give a boost to some states while reducing payments for others.

The vote, by a 59 to 39 margin, came as an amendment to a larger bill to replace No Child Left Behind, the country’s main K-12 federal education law. It marked the first time in decades that lawmakers have worked to change the formula for what is known as Title 1 funds, the largest single stream of federal dollars for elementary and secondary education.

The amendment, sponsored by Sen. Richard Burr (R-N.C.), was changed after behind-the-scenes protests from several Republicans as well as Democratic leaders Sen. Richard Durbin (Ill.) and Sen. Chuck Schumer (N.Y.), whose states stood to lose a greater amount under Burr’s initial plan.

Burr rewrote the amendment so that the formula changes would not take effect until Congress funds Title 1 at $17 billion annually. It is unclear when that would happen; the program is currently funded at $14.5 billion, an amount that has been steady since 2012. In addition, the change in formula would affect only dollars spent by Congress in excess of the $17 billion benchmark.

The federal government sends about $14 billion in Title I funds to the nation’s schools, handed out through a complex set of formulas that favors states with large populations and wealthy states that spend a lot on education. Rural states, and states with smaller populations, tend to receive less on a per-pupil basis.

About two-thirds of the nation’s public schools receive Title I dollars, according to the Center for American Progress.

Burr’s amendment would attempt to correct for that bias and would streamline the current set of four Title I formulas into one simpler formula. It essentially would dole out money based on the number of children living in poverty multiplied by the national average of the cost to educate that child.

Some believe the new formula would penalizes states that choose to spend more than the national average on education.

“While this is a huge improvement, it is still something that I think is very problematic, so I will be voting no on this,” Sen. Pat Toomey, (R-Pa.) said Wednesday. “The amendment is mistaken in two respects — it fails to recognize the varying cost of living in varying states and, second, it really penalizes those states that are willing to ask their citizens to invest more in education.”

Many states in the South and West would see an infusion of federal dollars, including Texas, California, Florida and North Carolina, Burr’s home state. Thirty-six states and the District of Columbia would gain a greater share of Title I dollars.

But 14 states would see fewer dollars than they would under the current system: Illinois, New York, Maryland, Virginia, Pennsylvania, New Jersey, Connecticut, Louisiana, Massachusetts, Michigan, West Virginia, Wisconsin, Ohio and Nebraska.

The Senate is expected to take a final vote on the bill Thursday afternoon.