WICHITA, KS (AP/WCMH) — A new law makes it illegal for police in Kansas to have sex with people they stop for traffic violations or detain in criminal investigations.

The Wichita Eagle reports the new law bans sexual relations “during the course of a traffic stop, a custodial interrogation, an interview in connection with an investigation, or while the law enforcement officer has such person detained.”

Kansas legislators who passed the bill say they were surprised to learn that such activity wasn’t already illegal in Kansas. In fact, before Gov. Jeff Colyer signed the law Thursday, Kansas was among 33 states where consensual sex between police and people in their custody wasn’t a crime, The Wichita Eagle reported.

Rep. Cindy Holscher, a Democrat, introduced the bill. She told the Wichita Eagle part of her inspiration was the case of Lamont McIntyre, a Kansas City man who spent 23 years in prison for a double murder that he did not commit. 

McIntyre was released last year after investigators determined the detective who arrested him had long coerced sexual acts from women in Kansas City’s black community, including McIntyre’s mother, by threatening to arrest them or their relatives. McIntyre’s mother said in an affidavit that she believed the detective targeted her son after she spurned his advances.

Holscher said she also was influenced by a New York case where a teenager alleged she was raped by two police officers in the back of their van. No charges were filed because the officers claimed the sex was consensual and therefore legal.

The Kansas bill received bipartisan support. Rep. John Carmichael, a Democrat from Wichita, said he was shocked to learn that such behavior wasn’t already illegal in Kansas when Holscher first discussed the proposal.

Many officers now wear body cameras, so it would be difficult for law enforcement to get away with sex on the job, said Rep. John Whitmer, a Republican from Wichita.

“Most officers are great guys and women who are working hard, but there’s always the one,” Whitmer said.

Information from The Associated Press contributed to this report.