Consider Revenge of the Nerds. Lewis has sex with Stan’s girlfriend, Betty, while posing as Stan. Does that qualify as rape? It might be a “casual” plot point for a movie, but what about in court in the real world?

In California, the answer was impostor sex is not rape for unmarried women–until now. A loophole from a law created in 1870 states that “a person who impersonates someone else to get consent for sex is only guilty of rape if the victim is married.” In other words, if a guy impersonated another’s lover and has sex with his victim, he was only committing rape if the woman had a ring on her finger. It boggles my mind that this law had been in effect for well over a century.

Even though some legislators had been trying to overturn this law since 2011, it was only after an anonymous 18-year-old was raped by Julio Morales that it started to garner serious media attention. The Los Angeles Times reports:

“A man enters the dark bedroom of an unmarried woman after seeing her boyfriend leave late at night, and has sexual intercourse with the woman while pretending to be the boyfriend,” the Los Angeles-based 2nd District Court of Appeal said in Wednesday’s ruling. “Has the man committed rape? Because of historical anomalies in the law and the statutory definition of rape, the answer is no, even though, if the woman had been married and the man had impersonated her husband, the answer would be yes.”

The court unanimously found Morales not-guilty due to the specific nature of this law.

Thankfully, Governor Jerry Brown closed the loophole last week after the conviction was overturned, clarifying that an attacker who impersonates someone else to coerce a victim into sexual activity can be prosecuted.

It’s rare that I celebrate the government doing something right, but this is a great example of how the courts can defend liberty. In my opinion, this is a classic consent and private property case. The victim could not have possibly given consent to Morales’s fraudulent sexual advances. In the original law, the victim was only allowed the right to defend her personhood in court if she chose to marry. The state is stepping in to protect women from facing criminals like Morales in the future. I laud Governor Brown’s decision to expand the law.