An American judge is under fire for deciding that a teenage boy accused of rape shouldn’t be tried as an adult in part because he came from “a good family,” had “very high” grades and because tougher charges could tarnish his future.

In a decision that has since been reversed by a New Jersey appellate court, Judge James Troiano ruled last July that the 16-year-old boy should not face charges in an adult criminal court after he was accused of recording the alleged rape of a 16-year-old girl at a pyjama party.

Prosecutors said the boy shared footage of the alleged rape with friends and texted them: “When your first time having sex was rape.”

Prosecutors pushed for the accused to be tried as an adult, but the judge denied that request. Troiano also chastised prosecutors for not explaining to the girl and her mother the harm it would cause to the boy to have adult criminal charges filed against him.

“This young man comes from a good family who put him into an excellent school where he was doing extremely well … He is clearly a candidate for not just college but probably for a good college. His scores for college entry were very high,” Troiano said in his decision last summer.

Prosecutors said the incident happened in 2016 at a pyjama-themed party with about 30 guests in attendance. According to an appellate court decision, the girl was visibly drunk at the party, slurred her words and stumbled as she walked.

The court said that, before the alleged sexual assault, a group of boys sprayed Febreeze on the girl’s buttocks and “slapped it with such force that the following day she had hand marks on her buttocks.”

At some point, prosecutors say, the boy led the girl into another room and filmed himself penetrating her. Prosecutors say the video shows the girl’s head repeatedly banging against a wall, and that friends found her vomiting on the floor after the incident.

The girl eventually reached out to police after she learned that the video was circulating among the boy’s friends, prosecutors said.

In his decision not to try the boy as an adult, the judge listed off the boy’s extracurricular activities, including the fact that he was an Eagle scout.

That ruling was later reversed by an appellate court. In a decision published online, the court pushed back against the judge’s “skeptical scrutiny” of a witness’s descriptions the video, including that the girl’s head banged against the wall.

“The judge also accorded great weight to the fact that (the boy) might have reasonably believed that (the girl) wanted to engage in sexual intercourse – without taking into consideration her level of intoxication – essentially accepting (the boy’s) defense theory as would the finder of fact at a trial,” the court wrote.

The court also raised doubts about whether being from “a good family” had any bearing on the case.

“That the juvenile came from a good family and had good test scores we assume would not condemn the juveniles who do not come from good families and do not have good test scores from withstanding waiver applications.”

The case is reminiscent of the trial of Stanford University swimmer Brock Turner, who was sentenced to six months in jail in 2016 for sexually assaulting an unconscious woman on campus.

In his sentencing decision, Santa Clara County Judge Aaron Persky cited the 20-year-old’s spotless criminal record and the potential effect that a harsher sentence would have on his future. Critics saw the sentence as far too lenient, and prosecutors pushed for jail time of up to 10 years.