For 22 years, Liu Yongbiao got away with murder while writing novels inspired by those murders. Then the police tricked him into giving himself up.

Chinese crime novelist Liu Yongbiao — who used the memory of four murders he committed 23 years ago as inspiration for his books — has now been sentenced to death for his crimes.

The Huzhou Intermediate People’s Court in the Zhejiang Province of China found Liu and his accomplice, Wang Mouming, guilty of both robbery and homicide after the two men admitted to their crimes. The two men were both then sentenced to death on July 30.

On Nov. 29, 1995, Liu and Wang checked into a guesthouse (akin to a hostel) in Huzhou, reportedly with the intention of robbing other guests. When the two were caught stealing by a guest, Wang and Liu are believed to have used clubs and hammers to kill the guest as well as the guesthouse’s two owners (an elderly couple) and their 13-year-old grandson in order to completely cover their tracks.

But at the time of the murders, there were no security cameras in place and that particular guesthouse kept no record of their guests, which left authorities stumped as to who had committed the killings.

“The biggest challenge was the suspects and the victims had no previous relationship,” said Xu Zhicheng, one of the local investigators, according to the news website The Paper. “It was very difficult for us to follow the vine to find the melon.”

Zhejiang Province Public SecurityLiu Yongbiao in custody soon after his 2017 arrest.

With police stumped, Liu Yongbiao was able to evade justice for more than two decades. What’s more, between the murders and his eventual arrest in 2017, Liu achieved moderate success as a crime author due to a series of novels that he wrote in the 2000s. In the preface to his 2010 novel The Guilty Secret, Liu even described his intention to write a story about a writer who gets away with committing a series of murders.

“I came up with the idea after reading some detective novels and watching crime shows and movies,” Liu wrote in the preface. “The working title is: ‘The Beautiful Writer Who Killed.’”

Despite clues like these, authorities had no explicit reason to connect Liu to the four 1995 murders. But in June 2017, now armed with new DNA technology, police were able to reopen the investigation.

Upon returning to the crime scene, authorities found a cigarette butt with Liu’s DNA on it. Police traveled to 15 Chinese provinces in order to link the DNA with a suspect and eventually were able to narrow down their suspect list and finally capture Liu Yongbiao.

Undercover cops arrived at Liu’s home and tricked him into thinking they were researching into his family tree, and Liu ended up giving them a sample of his saliva to match with the DNA sample from the crime scene. Two days later, Liu was arrested at his home.

One of the arresting officers told The Paper that Liu had already prepared a letter to give to his wife at the time of his arrest.

“I have been waiting for this day for 20 years and now it has finally come to an end,” he reportedly wrote. “Now I can free myself of this spiritual torment I’ve had for so long.”

After this look at Liu Yongbiao, read up on Michael Peterson, the novelist accused of killing his wife as seen in Netflix’s The Staircase. Then, discover the story of Blake Leibel, the graphic novelist convicted of torturing and murdering fiancée Iana Kasian in a manner consistent with a grisly graphic novel of his.