COLUMBUS, Ohio (AP) – A divided Ohio Supreme Court has declared unconstitutional a law that made it illegal for police officers to have sex with minors.

The court ruled 4-3 Thursday that the law arbitrarily added police to a ban on professionals having sex with minors that includes people with authority over children such as teachers or coaches.

Chief Justice Maureen O’Connor, writing for the majority, says the government can’t punish a class of professionals like police without making a connection between their job and the crime.

Dissenting Justice Sharon Kennedy said prohibiting police officers from having sex with minors serves a legitimate state purpose.

The law prohibited police officers from having sex with minors if the offenders were more than two years older than the victim.

(Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)