A judge in Idaho took a unique approach to sentencing last week, by ordering 19-year-old Cody Herrera, who was convicted of the rape of a 14-year-old girl, to not have sex until marriage. We're not 100 percent sure how this is legal. But then again, who the hell knows how the law works in Idaho?

According to the New York Times, the verdict was likely based on an archaic state fornication law that bans premarital sex. The penalty for violating this outdated rule is a fine of up to $300, plus six months in prison. While it's a law that isn't imposed, the District Court Judge who doled out the sentence, Randy Stoker, said that it would apply in this case because anyone on probation can't break a law of any kind.

We're guessing this will be appealed in the very near future.

Additionally, Stoker ruled that Herrera would serve a prison sentence of five to 15 years. However, Stoker suspended the sentence for a "rider program" that would last for one year. If Herrera completes this rider program, then he will be released from the program and placed on probation. One of the terms of his probation is that he won't be allowed to get laid until he gets married.

Stoker defended his bizarre ruling by saying that it was necessary because Herrera had told investigators that he had had 34 sexual partners. If that line's confusing to you (for any number of reasons) you're not alone.

"If you’re ever on probation with this court, a condition of that will be you will not have sexual relations with anyone except who you’re married to, if you’re married," Stoker told Herrera, according to the AP.

The crime that led to the unorthodox judgment reportedly occurred in March 2015, when Herrera was 18. The unnamed victim told the police that she told him she was 16 when they met. However, her mother discovered the relationship and told Herrera her daughter was 14, and wasn't permitted to have a boyfriend. Furthermore the mother told the court "It was his intent from the beginning to take what he wanted from my 14-year-old child—her virginity."

Herrera had been accused by the victim of assaulting her after she told him to stop touching her breasts. He pleaded guilty last March.