Three major U.S. cities filed a suit against the Pentagon that would require the military to submit to federal court monitoring of its compliance with a law to prevent firearms purchases by felons and domestic abusers — such as the Air Force veteran who in November perpetrated one of the deadliest mass shootings in American history.

“Our three-city coalition will right this two-decade wrong,” Ken Taber, the lead attorney in the case, told The Hill. “The executive branch and Congress have both had their chances to repair this clearly broken system. Now, after twenty years of failure, it’s time for the courts to step in.”

The lawsuit, filed by New York, Philadelphia, and San Francisco, alleges that Americans were endangered by the Defense Department’s failure to submit names and fingerprints of service members convicted of crimes to the Federal Bureau of Investigation’s national gun background-check database. The military is legally obligated to report felony-equivalent court-martial convictions and any convictions for domestic violence.

“The failure on behalf of the Department of Defense has led to the loss of innocent lives by putting guns in the hands of criminals and those who wish to cause immeasurable harm,” New York Mayor Bill de Blasio said in a statement.

The case was brought after veteran Devin P. Kelley murdered 25 people and an unborn child at a church in Sutherland Springs, Texas, on Nov. 5. A former Air Force logistics specialist, Kelley was court-martialed in 2012 on two Article 128 counts for assault in connection with an attack on his wife and their child. He was found guilty, sentenced to 12 months confinement, and separated from the service with a bad conduct discharge in 2014.

Had the Air Force reported Kelley’s criminal record to the FBI — as it was supposed to — he wouldn’t have been able to legally purchase the Ruger AR-15 variant (dubbed the AR-556), wielded in the massacre, from an Academy Sports & Outdoors in San Antonio last April. However, as The New York Times notes, he still would have been able to buy a rifle from private sellers who are not required to run background checks, thanks to an exemption known as the “gun show loophole.”

The day after the mass shooting in Sutherland Springs, Defense Secretary James Mattis ordered the DoD inspector general to conduct a joint review with the Air Force on how the service handled Kelley’s criminal records. According to the Pentagon, the IG would “also review relevant policies and procedures to ensure records from other cases across DoD have been reported correctly.”

The IG released its report in early December, concluding that the Army, Navy, Air Force, and Marine Corps did not submit fingerprint cards to the FBI for 24% of the 2,502 convictions handed down in courts-martial in 2015 and 2016. The branches also neglected to submit final disposition reports in 31% of the cases. Glenn A. Fine, the Pentagon’s acting IG, told the Senate that “there’s really no excuse” for the military’s reporting failures.

Officials in New York, Philadelphia, and San Francisco argue that their police departments rely on the FBI’s database to determine whether a person qualifies for gun ownership, the suit claims. It was filed in federal court in Alexandria, Virginia, and, according to The Hill, “asks for an injunction and judicial oversight to ensure the Pentagon complies with its legal duty to submit records.”

“After 20 years of failure, outside monitoring by the courts is clearly necessary to guarantee that the reporting failures that led to the Texas church shooting never happen again,” Adam Skaggs, one of the lawyers representing the plaintiffs, told The New York Times.

San Francisco City Attorney Dennis Herrera also chastised the Pentagon, saying in a statement on Dec. 26 that its “failure to fulfill its legal duty and accurately report criminal convictions puts innocent Americans at risk.”

“It is past time to ensure that we’re doing everything we can to keep guns out of the wrong hands,” he added.