First, he was convicted for dealing child pornography. Then he was sentenced to 50 years in prison. Now his conviction is overturned.

Attorneys for Christopher Wheeler, the former headmaster of an elite Delaware prep school, successfully argued before the state Supreme Court that warrants used to search his devices were unconstitutionally broad, the Associated Press reported after the court’s Wednesday ruling.

“The subject of this prosecution is an unsympathetic figure,” Justice Karen Valihura wrote, according to a copy of the opinion uploaded by the News Journal. “And the sexual exploitation of children is a dreadful scourge in our society.”

But, she said, quoting other decisions, the court’s role is to uphold the Constitution and fight against the temptation to let the ends justify the means. As a result, his conviction must be overturned, she concluded.

Wheeler was the former headmaster at Tower Hill School in Wilmington, whose well-known graduates include former DuPont Co. CEO Ellen Kullman, U.S. Sen. Chris Coons (D) and television personality Dr. Oz, according to the Associated Press.

“It’s just so wrong,” Judge Eric Davis said in 2014 when convicting Wheeler on 25 counts of dealing child pornography, one each for a separate image. “You should not have placed yourself in the position … where temptation faces you every morning as you shake hands with children.”

Davis’s comments mirrored those of one of Wheeler’s accusers: A man identified anonymously in the ruling who decided to come clean about his alleged molestation after former Penn State assistant football coach Jerry Sandusky earned national headlines over another child molestation scandal.

The man—identified only as “Mr. A”—told his brother about being abused by Wheeler three decades earlier, when he was 12 to 13 years old, only to discover that his brother had a similar story.

“I shudder at the notion that you, in your career, have chosen an environment that brings you into daily contact with other boys who are as old as I was when you molested me,” Mr. A wrote in a July 2013 letter to Wheeler, according to the warrant affidavits. That man’s brother, Mr. B, sent a similar letter.

Perhaps surprisingly, Wheeler replied.

“I will not compound your pain by attempting to deny or in any way deflect responsibility for my actions 35 years ago. I did those things. I am the one responsible. I’ll wait to hear from you about further appropriate steps towards resolution and restitution,” read the type-written response he allegedly sent.

In October 2013, authorities used previously obtained search warrants to search Wheeler’s residence and seize several of his devices. Three of them—an iMac, PowerBook and hard drive—contained more than 2,000 images of boys “engaged in sexual acts” and another more than 3,000 considered “child erotica,” according to the conviction ruling.

Wheeler was initially convicted at the end of 2014 and sentenced last year.