A Utah man will spend up to five years in prison for setting up cameras in bathrooms at two Magna Mormon churches and secretly recording underage girls.

James Steven Larsen, 40, also recorded family members at their Salt Lake County homes, according to court documents. Larsen told police a female relative was his “target,” but that he also wanted to “just catch whomever.”

He pleaded guilty to three counts of voyeurism, a third-degree felony, in December and was sentenced Tuesday by 3rd District Judge Richard McKelvie to up to five years in prison for each count, according to court documents. The prison terms will run concurrently.

Larsen was arrested in February 2017 in St. George after people renting a home in the city found a camera hidden behind a toilet and another hidden behind a trashcan in an upstairs bathroom and called police.

The cameras were arranged so they could record someone as they got into the shower and while they showered, according to court documents.

When the renters confronted Larsen, he “confessed to everyone,” according to court documents.

Once arrested, he told police he had keys to two The Church of Jesus Christ of Latter-day Saints churches in Magna — one at 3606 S. Wing Pointe Drive and the other at 7731 W. 3500 South — and would place the cameras in the bathrooms early Sunday and retrieve them on Monday.

Larsen also told police he placed cameras in bathrooms at his relatives’ homes.

The clandestine cameras captured images of multiple people, including minors.