New legislation intended to close a loophole that allowed some convicted rapists to go free is on its way to California Governor Jerry Brown’s desk.

Current law only protects married victims who are fooled into thinking a rapist is their spouse. The new bill, which was drafted in response to a recent Southern California court ruling, would expand this protection to unmarried victims.

Assembly Speaker John Pérez is a co-author of the legislation.

“This bill closes a loophole that resulted in a grave miscarriage of justice that allowed a man convicted of rape to have his conviction overturned simply because the woman who was raped was not married at the time that she was attacked," said Pérez.

The ruling in question overturned the rape conviction of a man who impersonated his victim’s boyfriend. The court ruled that California law only protected married victims of rape in such cases of impersonation.