COLUMBIA, S.C. (AP) — A House panel has advanced a bill designed to prevent people who have been declared mentally ill from buying guns.

The vote sends the bill to the Judiciary Committee. It ensures the names of those determined mentally insane by a South Carolina court are put into a federal database for purposes of background checks for gun purchases.

Democratic Rep. Leon Stavrinakis of Charleston says the safety reporting bill closes a glaring loophole.

It’s already illegal to sell guns to someone who is mentally ill. But the lack of reporting means gun shops don’t get that information when they run a check.

Last month, authorities charged a 28-year-old woman with trying to fire a handgun at a Charleston girls’ school. No one was hurt because she had loaded the gun incorrectly.