A former New York Police Department officer admitted to spying on his colleagues because he wanted to find out who his ex-girlfriend was dating, the New York Daily News reported.

Detective Edwin Vargas will spend four months in a federal facility for using a computer hacking service to obtain the passwords of 30 other cops at the 40th Precinct in the Bronx. The 43-year-old's sentencing comes after he pled guilty to charges of conspiracy to commit computer hacking and unauthorized access of a law-enforcement database last November, the newspaper reported.  

He was sentenced on Monday during an appearance in front of a Manhattan Federal Court judge. Vargas, who has a son with his ex-girlfriend, will get to keep his pension in exchange for his guilty plea. He is to begin his sentence in August.

"I'd like to apologize to all the victims in this case," Vargas told Judge Kevin Castel before he was sentenced, the Daily News reported. "I never meant to hurt anyone."

The former detective first hired the computer hacking service in April 2010. He paid the service to obtain email passwords belonging to 30 of his fellow officers, a total of 43 email accounts.

Vargas also used a federal database to look up more information on his colleagues.

Peter Brill, Vargas' lawyer, said his client kept tabs on other officers at the precinct because he wanted to find out if any of them were dating his former girlfriend, who is also a cop. Vargas' actions were "jealousy inspired," the lawyer said according to the newspaper.

Castel noted that Vargas, a police officer for 20 years, had "a distinguished career serving the people of this city." Brill requested his client be spared jail time, but the judge said Vargas committed "a crime that warrants punishment," the Daily News reported.  

Vargas apologized in court to his son and ex for what he did. They were not present for the sentencing.

"I'll strive to be a better person each day," Vargas said.