A drug counselor who let students have sex in his office at Salinas High School while he secretly videotaped them pleaded no contest on Tuesday to 56 counts.

Gilbert Olivares, 36, of Salinas, agreed to serve 16 years in state prison and will have to register as a child sex offender for life. The 56 counts included committing lewd acts upon a child and manufacturing child pornography.

Olivares used his position as a counselor to get teenagers out of class to spend more time with him, and told students they could have sex with each other in his office, police Sgt. Christopher Lane said. Detectives said they found 13 videos made by Olivares.

"The videos are of teenage students engaged in sexual activity with each other within Olivares' office, during school hours. It appears the videos were taken without the knowledge of the victim students, and Olivares is not in the room at the time," Lane said.

Investigators said they found no evidence that the videos were ever distributed or shared.

His defense attorney, Richard West, said he accepted the plea deal offered by Monterey County District Attorney prosecutors so that victims would not have to experience any more trauma during a trial.

"Mr. Olivares has always been looking to avoid any further trauma or any further detriment to any victims in this case, so I think to that extent, he is taking responsibility for his actions," West said.

Olivares was not an employee of the Salinas Union High School District. He was employed by Sunrise House, an organization that counsels teenagers on drug and alcohol abuse.

Concern about Olivares was first raised when a 14-year-old boy's family noticed a change in the teen's behavior, police Cmdr. Vince Maiorana said. The boy's sister found sexually-explicit private Facebook messages sent by Olivares and she alerted police.

In addition to Olivares' prison sentence, he may be required to pay restitution to victims. He will be sentenced by a judge on May 28.