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. 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.

California’s code previously stated that a crime was rape if the victim was unconscious or asleep or “submits under the belief that the person committing the act is the victim’s spouse.” In this case, the woman simply thought the man having sex with her was her boyfriend, not her husband.

On Monday, California Gov. Jerry Brown signed a bill that closes the loophole. It was apparently a three-year effort to get the bill passed and signed into law.

California law now clarifies that “an attacker who coerces a victim into sexual activity by impersonating somebody else can be prosecuted for felony rape,” according to a state lawmaker’s news release.