A teacher at an elite boarding school in New Jersey used his position as a dorm “duty master”—who is responsible for nightly check-ins with students—to molest two teens while they slept, police said.

Dominic Brown, a 23-year-old history teacher and water polo coach at The Lawrenceville School, was charged with endangering the welfare of a child and two counts of aggravated criminal sexual contact, the Mercer County Prosecutor’s Office said in a Monday press release.

But an affidavit filed by the prosecutor’s office and obtained by NJ.com shines more light on the allegations.

Brown used his position as “duty master” to enter a 15-year-old student’s room around 3 a.m. and touch the sleeping teen, who awoke to see Brown trying “to fall to the floor to hide from me,” according to the affidavit.

The teacher also allegedly claimed that the teen hadn’t checked in to the dorm that night, and he was making sure he was in his room. (The Lawrenceville School student handbook stipulates that students must report in person to the “duty master” each night before bed.)

About an hour later, a 14-year-old boy was similarly awakened by hands touching his body, and he found Brown “crouching partially under the side of his bed,” the affidavit alleges. Though Brown reportedly left the room after the student confronted him, the teen told police that he peered back inside a short time later.

The students, who were reportedly in a group Snapchat message together, relayed their similar experiences and then told campus security, who notified police.

Brown has since been fired, NJ.com reported. Prosecutors said he will remain in jail until a Thursday morning detention hearing.