Like many American mass shooters before him, Devin Kelley, who attacked Texas churchgoers on Nov.5, killing 26, had a history of domestic violence. He had been court-martialed by the US Air Force for attacking his wife and toddler stepson—fracturing the boy’s skull—and served 12 months in jail before being dishonorably discharged.

By federal law, people convicted of domestic violence are banned from purchasing firearms, and yet Kelley was able to buy the military rifle he used to shoot his victims, as well as three other guns. Because of what appears as a mistake by the Air Force, his conviction wasn’t reported to the federal authorities and was not flagged in background checks.

According to US senators Jeff Flake, an Arizona Republican, and Martin Heinrich, a Democrat from New Mexico, this wasn’t so much an oversight as a consequence of a loophole that stops domestic violence while in the military from being effectively reported to the National Instant Criminal Background Checks (NICS) system. Military courts wrap charges of domestic violence under the broader label of “assault,” so they risk being overlooked in databases.

As Flake—who with Heinrich introduced a bill to create the Domestic Violence Loophole Closure Act (pdf), notes—ever since the NICS system was created in 2007, the Defense Department has only reported one case of domestic violence.

“Since the military has no defined charge under the uniform code of military justice for domestic violence, convictions in military courts have gone unreported,” said Flake told reporters when introducing the bill. “This egregious oversight has allowed individuals such as the Texas shooter, who otherwise should not have been able to legally purchase a firearm, to do so.”

The bill would mandate reporting military convictions for domestic violence within three days. The measure would also require reporting convictions civilian courts would count as domestic violence.