Three U.S. cities filed a federal lawsuit against the Defense Department that would require the federal judiciary to ensure the Pentagon reports to the FBI records of service members who cannot legally purchase or possess firearms.

New York City, Philadelphia, and San Francisco joined together to file the lawsuit in federal district court in Alexandria, Virginia, on Tuesday over what the cities said are “repeated failures” by the Defense Department to report to the National Instant Criminal Background Check System criminal histories and dishonorable discharge information.

The lawsuit follows the November shooting at a church in Sutherland Springs, Texas. Gunman Devin Patrick Kelley, who received a bad conduct discharge from the Air Force, shot and killed 26 parishioners and injured 20 others.

Kelley was able to successfully purchase two firearms even though he was convicted of assaulting his then-wife and stepson in 2012.

His conviction should have prevented him from buying the firearms, but Air Force personnel at Holloman Air Force Base in New Mexico failed to report his court-martial to the FBI.

“This 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 City Mayor Bill de Blasio said in a statement.

The three cities are suing because they “regularly rely upon the integrity of the FBI’s background check system,” according to the Giffords Law Center to Prevent Gun Violence, which helped develop the case.

The lawsuit seeks an injunction and judicial oversight to ensure the Pentagon submits to the FBI current and past disqualifying records to be included in the national background check system.

The Department of Defense would also be required to regularly report its ongoing compliance to the federal judiciary.

“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. That’s exactly what this lawsuit aims to accomplish,” Adam Skaggs, chief counsel of the Giffords Law Center to Prevent Gun Violence, said.

According to a report from the Department of Defense Inspector General released earlier this month, the Air Force failed to submit disqualifying records to the FBI in 14 percent of cases. The Navy failed to submit records in 36 percent of cases, and the Army failed to do so in 41 percent of cases.

“Philadelphia, which for years has been plagued by gun violence, relies on this reporting when making the crucial decision whether a license to carry applicant should be permitted to carry a firearm,” Philadelphia Mayor Jim Kenney said in a statement. “We’re joining in this suit because reporting these records is absolutely critical to those decisions. The background check system only works if it contains the proper records.”