A former high school teacher who admitted to having sex with a student was sprung from jail Wednesday, thanks to a state loophole reducing her charge.

Sarah Lewis was accused of rape in January after a 17-year-old male student said she plied him with vodka and had sex with him –which he recorded, KUTV reported.

Lewis, 27, a dance and social studies teacher at Landmark High School, pleaded guilty to forcible sexual abuse in June, a second-degree penalty which holds a possible sentence of one to 15 years, the station reported.

Lewis’ lawyer, Tom Means, filed a motion to dismiss her guilty plea in July, after saying he’d found an amended statute in Utah Code that could have reduced her original rape charge even more, KUTV reported.

The law, amended in 2014, allows teachers or others with “a relationship of special trust,” who have been charged with raping a 16 or 17 year-old, to reduce their charge to unlawful sexual conduct, a third-degree felony.

“Because I was unaware of the amendment… until after Ms. Lewis offered her plea I did not advise her of this change in the law that affected the degree of the offense to which she pled,” Means said, according to the Daily Herald.

Following the lawyer’s discovery, Lewis was charged with the third-degree felony and was released from jail, where she’d spent the last 195 days.

One defense lawyer said the amendment is no loophole.

“I don’t consider this a loophole,” Stephen Allred, a defense attorney with Zabriskie Law Firm, told the channel. “These 16 and 17 year olds do have a choice, and they have chosen to engage in this,” he said, adding that legislators amended the law to, “take the teacher portion out of the equation.”