Behind the scenes Wednesday at the state Capitol, before the legislature voted on a deficit mitigation package, Rep. John Frey of Ridgefield, scrambled to get his idea into the legislation.

The legislation to erase the $365 million budget deficit was already drafted and ready to be finalized when Frey brought the idea to legislative leadership.

The idea: allow municipalities to use money it receives for local capital improvements on school security upgrades.

Frey, whose two nieces and nephew attend Sandy Hook Elementary School where 20 children and six adults were murdered by a lone gunman last week, said it was the least he could do.

Typically, Local Capital Improvement Program funds are used to improve sidewalks or streetscapes, but now the $30 million available under the program can be used to improve school security.

“This legislation will help any town, who may not ordinarily have the funds available, ensure that our children have what they need to be safe in their schools,” Frey said.

Legislative leadership on both sides of the aisle were happy to accommodate Frey’s last-minute request. It passed both the House and the Senate Wednesday night.