A Samoan man was kept in prison for nearly five years longer than he should have been because of an administrative error.
Sio Agafili, 45, was meant to have been released in December 2015, but the error was only picked up on by a judge when he appeared in the Supreme Court last week.
"He's been imprisoned unlawfully," said Muriel Lui, who was appointed as Agafili's lawyer by the court when the error was spotted.
Lui said she was concerned there could be plenty more prisoners like Agafili languishing in Samoa's much-maligned prison system because of basic errors.
"I've heard of other cases of a similar nature," she said. "This is not the first of this type."
Agafili was convicted of burglary and theft in November 2008, when he was sentenced to seven years in prison. Then, in December 2008, he was convicted on unrelated counts of burglary and theft, and sentenced to five years in prison.
Those sentences were meant to have been served concurrently, Lui said, which is the default in the Samoan system. That means he should have been released in December 2015, after the seven years lapsed.
But it was only last week that Justice Leiataualesa Daryl Clarke noticed the error, ahead of Agafili's appearance over an assault at Tanumalala prison.
"He didn't realise anything. He didn't realise that it was supposed to be concurrent, and it was only picked up when he came up for sentence for the current offence he's been charged with," said Lui.
In court, the police, through the Attorney General's office, conceded Agafili was detained illegally, and he was released on bail ahead of his sentencing for the latest conviction at the end of the month.
Agafili's four years and eight months of added detention has raised further questions about Samoa's prison system, which has been through years of tumult and accusations of inhumanity and incompetence.
In March, the entire Prison Service was disbanded and senior managers sacked after the latest in a series of break outs, this time by 36 prisoners. It was taken over by the Ministry of Police, whose commissioner promised a complete overhaul.
Reports from both domestic and international rights groups have criticised the prison system for a lack of staff, ambivalent or incompetent management, overcrowding and a lack of basic facilities like running water.
A report by Samoa's Ombudsman last year said there was little classification of prisoners and that a lack of proper record keeping was one of its most pressing concerns.
"Despite the availability of some ... books for record keeping, there is still a major gap in that most of them are not comprehensive, records are not entered correctly and some are incomplete," the Ombudsman's report read.
"This is a serious concern which not only violates the rights of the prisoner but also puts the centre at risk especially when it comes to investigations."
Muriel Lui said the fact her client lost nearly five years of his life to poor record keeping had her concerned that many others would be having the same experience.
"I'm not quite sure what happened here in terms of how police entered into their system that it was cumulative instead of concurrent, but it definitely does raise questions in terms of other prisoners who are currently in there, and whether they are serving the right sentences."
RNZ Pacific asked both the Police and the Attorney General's office whether they were trying to determine if anyone else was in prison who shouldn't be, and whether any form of investigation was underway. They did not respond to requests for comment by deadline.
Meanwhile, Sio Agafili's been reunited with his family for now. Muriel Lui said she was discussing his legal options for him, and it's likely a claim for compensation would be made.
"His right to liberty - under article 6 of our constitution - has definitely been breached. So it'll definitely be a claim under that."