Medical examiners at the Institute of Legal Medicine in Ovedia, Spain were soon to be performing an autopsy on a 29-year-old prisoner who had died suddenly in his cell on Sunday, or so they thought—until they heard snoring. Guidelines for incisions had reportedly already been marked on Gonzalo Montoya Jiménez’s body before mortuary workers discovered that he was alive, despite three different doctors certifying his death, according to the Miami Herald, pulling for European and Spanish-language sources.

The incident began when prison guards found Jiménez, who was serving time for theft at Villabona Jail, unresponsive in a chair in his cell, blue in color with no apparent signs of life, according to The Telegraph. Two doctors at the prison, as well as a forensic specialist, declared the prisoner dead, and he was transported to the Institute of Legal Medicine morgue, where he saved by his own snoring as he lay on a metal table just hours away from his own autopsy.

Jiménez did not regain consciousness until Monday after being transferred to a hospital, according to International Business Times. Doctors said that although he may have suffered a lack of oxygen to the brain during the ordeal, he was still able to speak and remember things, which was a positive sign. Villabona Jail has opened an investigation into the incident.

Doctors said the prisoner did not have a pulse when he was initially discovered, the Miami Herald reports, and there were no signs of foul play. A spokesman for the Spanish Prison Service issued a statement saying, “I can’t comment on what happened at the Institute of Legal Medicine, but three doctors have seen clinical signs of death so it’s still not clear at the moment exactly why this occurred.”

Some suggested catalepsy was the potential cause of Jiménez’s condition, The Telegraph reports. Catalepsy is a condition that can cause immobility and a decreased response to stimuli, according to the National Center for Biotechnology Information. However, the prisoner’s family reported that overdosed on barbiturates in a suicide attempt, and this overdose combined with hypothermia might have made his vital signs undetectable, The Telegraph said.

The family criticized the prison’s alleged failure to keep proper control over medications and said Jiménez was taking medication for epilepsy and anxiety, according to The Telegraph. They also suggested that only the first doctor examined Jiménez while the other two simply signed off on the first doctor’s determination.

Jiménez is not the first person found to be alive after being declared dead and placed in a mortuary. In 2014, a 91-year-old Polish woman began moving in her body bag after 11 hours in a mortuary while her family was already making plans for her funeral, BBC News reported. Two years earlier, a premature baby believed to be stillborn was discovered alive in an Argentinian morgue, 12 hours after she was pronounced dead by medical staff.