New York lawmakers passed a bill Thursday that bans police officers from having sex with people in custody, the New York Daily News reported.

The bill, which says that detained people are unable to consent to sex, would close a legal loophole that let police officers avoid sexual assault charges by saying sex with people in custody was consensual.

Last month, BuzzFeed reported that many states do not have laws explicitly defining sexual contact between officers and detainees as nonconsensual. At least six states have passed bills to change such laws.

ADVERTISEMENT

In New York, laws allow an officer to say they had consensual sex with someone in their custody and be convicted of, at most, a misdemeanor for official misconduct.

The bill passed after two on-duty New York City police officers allegedly raped an 18-year-old woman in their police van last year after she was arrested on marijuana charges.

DNA from a rape kit matched the two officers but both have pleaded not guilty to rape and other charges.