A woman whose home was populated by starving cats who had eaten some of their own to survive will have to go back to court to see if she can avoid a trial and possible jail time.

A New Jersey state appeals court ruled Monday that a judge erred last year when he allowed Jill Petruska to enter a pretrial intervention program that would have allowed her to eventually clear her record if she met certain conditions.

Investigators removed 13 live cats from Petruska's Nutley apartment in 2016 and estimated that 12 others had died, though they said getting an accurate number was difficult because animal parts were strewn around. Nutley is about 8 miles (12 kilometers) from Newark.

Petruska said she'd been away and caring for a sick relative but had stopped by periodically to care for the cats. She was charged with 26 counts of animal cruelty. A phone message was left Monday for her attorney.

According to Monday's court filing, the stench from the carcasses and cat feces was so strong that police had to use the fire department's ventilation equipment and wear hazardous materials suits to enter the apartment.

A veterinarian testified to a grand jury that some of the cats had given birth in the apartment and eaten their offspring to survive, the court filing said.

In early 2018, despite opposition from prosecutors, a judge granted Petruska's request for admission into a pretrial program that forbade her from owning or caring for animals for two years and required her to perform 200 hours of community service and undergo counseling.

Monday's ruling disagreed with how prosecutors applied state guidelines to Petruska's request, but still sent the case back to be heard by a different judge. Specifically, it cited the original judge's refusal to look at photographs from the apartment showing the decomposed animals.

"These conditions surely did not evolve over a short period of time and belied defendant's claim to have periodically stopped by the apartment to feed the cats or to have arranged for someone else to take care of the cats," the appeals court wrote.