Washington (CNN) Sens. Jeff Flake and Martin Heinrich are planning to introduce bipartisan legislation that will make it a law for military to report misdemeanors of domestic violence to the National Instant Criminal Background Check System, the database used for firearms background checks.

Flake, a Republican, and Heinrich, a Democrat, are introducing the legislation after gunman Devin Patrick Kelley, who killed 26 people inside a small Texas church on Sunday, was armed with an assault rifle and 15 loaded magazines in the deadliest shooting in Texas history. He had previously been convicted of domestic violence by a military court.

"Writing a bill w/ @MartinHeinrich to prevent anyone convicted of domestic violence -- be it in criminal or military court -- from buying a gun," Flake tweeted Tuesday.

"Senators Flake and Heinrich are working to ensure any individual convicted of domestic violence -- whether it is in criminal or military court -- cannot legally purchase a firearm," a source close to Flake told CNN. "Currently, the military is not reporting misdemeanors of domestic violence to NICS, the database utilized for firearms background checks, and it's not clear that they can under current law. Their bill will permanently close this loophole, which was exploited by the shooter in Sutherland Springs, Texas."

The military does have an affirmative obligation to report criminal verdicts within the civilian database -- which if it had been done in the case of Kelley -- would have alerted law enforcement to his violent history and prevented him from buying a fire arm under federal law.

"This is true whether or not the statute specifically defines the offense as a domestic violence misdemeanor. For example, a person convicted of misdemeanor assault against his or her spouse would be prohibited from receiving or possessing firearms," according to a provision in the Federal Gun Act of 1968.

On Monday, the Air Force acknowledged it did not relay Kelley's court martial conviction for domestic assault to civilian law enforcement that could have prevented him purchasing the firearms used in the shooting.

Kelley was court-martialed in 2012 for two counts of Article 128 of the Uniform Code of Military Justice, assault on his spouse and assault on their child, spokeswoman Ann Stefanek said Monday. Kelley received a bad conduct discharge, confinement for 12 months and a reduction in rank, she said.

The failure to relay the information prevented the entry of his conviction into the federal database that must be checked before someone is able to purchase a firearm. Had his information been in the database, it should have prevented gun sales to Kelley.

Flake announced that he will not run for re-election last month in a blistering speech on the Senate floor that bemoaned the "coarsening" tenor of politics in the United States.

Sen. John Cornyn, the Republican whip, also told CNN that the Senate judiciary committee will hold a hearing on bump stocks, which allow semi-automatic weapons to function like automatic weapons, and expect the Bureau of Alcohol, Tobacco, Firearms and Explosives to testify "about what the best and most efficient approach would be" for dealing with them. They also plan to ask whether the ATF has the legal authority it needs to regulate them.

Cornyn says he and Democratic Sen. Dianne Feinstein requested the hearing. There are no additional details about when the hearing would take place.

Cornyn is working on two separate bills that he hopes will increase reporting to the background check system. One addresses ensuring the military and federal government upload background check data, the other is aimed at incentivizing states to do the same.

Cornyn said he would introduce legislation to ensure federal agencies and the military upload that data in a timely way. He cited Department of Justice statistics that show the number of records uploaded into the system is "staggeringly low."

The second-ranking Republican leader in the Senate said he would work on a separate but similar bill to encourage states to provide the data.

"The Department of Defense and the Air Force clearly fell down on their responsibilities because it's already a matter of federal law. The challenge is dealing with the states. We can't constitutionally mandate the states comply but we can provide a mixture of carrots and sticks to encourage them to report this information," Cornyn said.

Cornyn said he was in discussions with three Democratic senators about writing the legislation, including Heinrich, Chris Murphy of Connecticut and Jeanne Shaheen, and that they would "go back to the drawing board" to figure out how best to improve the system. He said new grants for states was a likely option.

"We're interested in trying to find a way to work together to deal improving the background check system and fixing these holes and find some better incentives for the states to comply," he said.

Cornyn said he would meet later in the day with the chief of staff of the Air Force to try to determine why the information about the Texas shooter wasn't uploaded.

This story has been updated and will continue to update with new developments.