A former Hillsborough police officer has pleaded guilty to two counts of indecent liberties with a minor, following an internal investigation conducted by the Hillsborough Police Department in 2013.

James Riley Jr., 62, of 708 Phelps Road in Hillsborough, was fired by the department days after its internal investigation—which included nine nights of surveillance—found “potential criminal conduct” in July 2013, the town said in a release. The Orange County District Attorney’s Office filed charges against Riley in April 2014.

Riley, who had worked for the department since January 2004, received a 20- to 33-month suspended jail sentence and was ordered to surrender his law enforcement certification and perform community service. He is currently on probation and was required to register as a sex offender with the state.

According to the registry, Riley was convicted for separate offenses in December 2011 and July 2013. Both victims were 13 years old at the time.

The investigation stemmed from a complaint the town received in April 2013. Even though Riley was off duty at the time of the offenses, the court cited his use of his position as an officer as an aggravating circumstance, the town said.