A man says his life was saved when he was arrested for drug dealing.

When Matthew Parker, 39, arrived at prison a medical check showed that unless he stopped taking drugs he would be dead within a matter of months.

While in custody he had been able to kick the habit, he had put on weight and had gained qualifications, a court heard on Friday.

Parker, of King Street in Leeswood near Mold, admitted conspiracy to supply class A drugs and received a 28-month prison sentence.

His case had earlier been adjourned when his basis of plea was rejected by the prosecution – but other members of the gang, said to have “stupidly” filmed themselves dealing on their mobile phones, were jailed.

On Friday prosecutor Brett Williamson described as “ridiculous” Parker’s claim that he had lost the SIM card from his mobile phone and that he did not know how it ended up in a Mold drugs den.

But he had dropped his claim that he had only been involved in drug supply on four occasions within the conspiracy.

Defending barrister Robert Edwards said Parker knew that if he had not been arrested and remanded in custody then he would have been dead within a matter of months.

In his own words, Parker described it as “the best thing that happened to me” because he had to face his demons and was forced to get help.

His addiction to class A drugs had to an extent been exploited and in his state he was not aware of the scale of the operation.

But the 6ft 1ins man who weighed 7st 11lbs on his arrest now weighed 12st 2lbs after he had been able to tackle the drugs issue which had blighted his life for a considerable period of time.

Judge Niclas Parry said that Parker more than anyone should understand the harm that he was causing by being involved in supplying the most harmful drugs in the Mold and Flintshire area.

“They nearly killed you. You were supplying them and they could have killed other people,” he said.

He was playing a significant role as a street dealer which had a starting point in sentencing of four-and-a-half years and the sentences could go up to seven years, he warned.

But he was chronically addicted to the drugs he was supplying.

He was in an “utterly pathetic state” at the time and did not have any influence on anybody else within the gang.

Judge Parry said that he had read the defendant’s letter and it was clear that he was making good use of his time in custody and had obtained construction qualifications.

The judge said that if he offended again then he would go back into custody.

Parker told him: “There is no chance of that, your Honour.”

Earlier this month the court heard how mobile phone films showed how a flat in Mold was being used as a drugs factory where heroin and crack cocaine was brought in, packaged and sold on.

There were text messages including drugs adverts but police found even better evidence – they had filmed themselves dealing.

The footage showed a flat in Mold which was the hub of their operation where dangerous class A drugs were brought from Liverpool. It was said to be awash with drugs.

Three other men were jailed and a woman who lived in the flat received a suspended sentence.