Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

By the time Rafael Ruiz was released from prison, he had spent half his life there.

Ruiz, now 60, was convicted of a sexual assault in 1985, sentenced to 8 1/2 to 25 years in prison, and served the maximum.

Ruiz was released on parole in 2009, but still had the conviction hanging over him, even though he had always maintained his innocence, which ironically contributed to his long sentence.

But on Tuesday, after 35 years, the New York State Supreme Court vacated Ruiz’s conviction and dismissed all charges against him, based on DNA evidence, according to the Innocence Project, which has been working with the Bronx man for more than a decade.

While Ruiz can't do all the moves he could as a young man, news of his exoneration had him dancing.

“Sometimes when I feel really happy, I just do it. I don’t care about my knees or anything. I just do a little break dance,” Ruiz said.

“I lost 25 years of my life because I insisted upon my innocence and rejected plea bargains," he said. "Today feels like a huge burden off my shoulders and I look forward to living a good life moving forward.”

Ruiz was accused of being one of three men who sexually assaulted a woman on a Harlem rooftop in 1984.

The victim said the name of the man who led her to the roof, and went to an apartment to get the two other men, was "Ronnie."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

But when she was asked what apartment the men came out of, she pointed to Ruiz's brother's apartment.

Ruiz agreed at the time to be questioned by police and photographed "without understanding how his photo would be used," according to the Innocence Project.

The photo ended up in a lineup with five other men, all of whom had afros even though the victim did not describe Ronnie as having an afro. The victim said Ruiz looked most like her attacker.

Ruiz was initially offered a plea deal of 1.5 to three years "suggesting that prosecutors recognized the weaknesses of the evidence in this case," according to the Innocence Project. But he refused to take the deal because he would not plead guilty to a crime he insisted he had no part in.

Ruiz's 25 year sentence is a perfect example of what is called the “trial penalty,” in which defendants face substantially longer sentences because they took their case to trial, the Innocence Project said. Eighteen percent of known-innocent and exonerated people pleaded guilty, likely to avoid such a penalty.

“I was a man who went to court and went to trial to prove his innocence, but I was treated like I was already guilty when I stepped in there,” Ruiz said.

While Ruiz was incarcerated, he and his family asked for help from attorney William Tendy, who thought he would only spend a few hours on the case, but became convinced that Ruiz was innocent and ended up spending three years working on Ruiz' case in his spare time, without pay.

He discovered that a man with a history of violence against women, who fit the victim's description of her assailant, lived in the building where she was raped. That man's name was Ronnie, and he lived across the hall from Ruiz's brother.

Tendy referred Ruiz's case to the Innocence Project, which, along with New York County District Attorney’s Office’s Conviction Integrity Program, arranged for the victim's sexual assault kit to be tested.

Every sample tested excluded Ruiz as a suspect, leading to his exoneration.

"We now know that police conducted an inadequate investigation marked by unduly suggestive identification procedures," Seema Saifee, a senior staff attorney with the Innocence Project, said. "This led to the conviction of a young man with limited resources who bravely insisted he was innocent."

Sixty-nine percent of wrongful convictions overturned by DNA evidence in the U.S involved mistaken eyewitness identifications, like Ruiz's, according to the Innocence Project. And while a 2017 law was passed to mandate best practices in eyewitness identification procedures, none of the requirements would have prevented any of the missteps that put Ruiz behind bars for a quarter of a century.

That's why Ruiz hopes that his case might help others who have been wrongfully convicted.

While he was in prison, many people tried to help him by finding cases similar to his that he might be able to use to help prove his own innocence. But they could not find any.

“I guess now I might be one of the cases or life stories in those law books that someone can use and hopefully it can help them out with their cases," Ruiz said. "That makes me feel good."