A new Kansas law makes it illegal for police to have sex with people they stop for traffic violations or detain during criminal investigations.

Kansas legislators who passed the bill say they were surprised that such activity wasn't already illegal in the state.

Gov. Jeff Colyer signed the bill Thursday as part of several law enforcement-related measures.

The Wichita Eagle reports Kansas was one of 33 states where consensual sex between police and people in their custody isn't a crime.

Rep. Cindy Holscher, an Olathe Democrat, sponsored the bill. She said state law previously said police could not have sex with people in jail, but it didn't address situations where people are stopped or were in custody as part of criminal investigations.