PHILADELPHIA (CBS)—A retired New Jersey police chief pleaded no contest to charges that he scammed an elderly man out of nearly $30,000.

Robert Ryan, 71, of Factoryville, who had worked 30 years as a police officer in Garwood, New Jersey, told a judge on Monday that he, too, had lost $30,000 to a Jamaica-based hoax and that his crimes were an attempt to recover his losses.

READ MORE: Psychologist Offers Advice On How To Talk To Kids About The Texas School Shooting

Authorities say Ryan was arrested on Dec. 22, 2016, after Wells Fargo Bank employees called Northampton police to their branch in Richboro. Investigators found Ryan there with the 95-year-old victim, who was attempting to withdraw $3,800 from two accounts.

Bank employees blocked the transaction because more than $20,000 already had been withdrawn that month from the victim’s accounts, court records show.

Police: Psychic Scammed Man Out Of $147,700, Claimed He Had Eight Evil Spirits

The victim told police that he had been contacted earlier in the month by a man calling himself James Holliday, who told the victim that he had won $33 million in a lottery. The man told the victim that a courier would be coming by to pick up money needed to pay taxes before the prize could be claimed.

The victim told police that Ryan had stopped by several times to pick up five other checks he had written so that he could claim the alleged jackpot. Each of the checks had been made out to and endorsed by Ryan.

READ MORE: Body Found At Broomall Auto Body Shop Owned By Missing Man George Hughes, Police Say

By the time of Monday’s hearing, Ryan had spent five months in the Bucks County Correctional Facility, an experience he described as “horrendous.”

Ryan pleaded no contest to charges that included four felony counts of theft by deception.

“He seems to be a very nice man. I never intended to hurt him,” Ryan said of the victim, who sat in a wheelchair in the back of the courtroom and did not speak. “I was just trying to get my money back. It was a very foolish mistake for me to make, being a former law enforcement officer.”

According to authorities, Ryan said he had suffered a series of strokes that he believed had affected his judgment. He said he never learned the true identities of the scammers, and that he had given them all but $1,000 of the money he received from the victim.

Police said that after Ryan’s arrest, his phone rang continuously from what purported to be a Jamaican callback number.

MORE NEWS: Off-Duty Officer Thomas Munz Jr. Killed While Riding Motorcycle In South Philly Was Involved In Fatal Shooting Of Walter Wallace Jr.

A judge sentenced Ryan to serve 23 months behind bars, followed by five years of probation. Ryan was ordered to repay the victim’s losses, totaling $28,900, in monthly increments of no less than $200 each.