YouTube’s automated recommendation system — which drives most of the platform’s billions of views by suggesting what users should watch next — had begun showing the video to users who watched other videos of prepubescent, partially clothed children, a team of researchers has found.

YouTube had curated the videos from across its archives, at times plucking out the otherwise innocuous home movies of unwitting families, the researchers say. In many cases, its algorithm referred users to the videos after they watched sexually themed content.

The result was a catalog of videos that experts say sexualizes children.

“It’s YouTube’s algorithm that connects these channels,” said Jonas Kaiser, one of three researchers at Harvard’s Berkman Klein Center for Internet and Society who stumbled onto the videos while looking into YouTube’s impact in Brazil. “That’s the scary thing.”