YouTube has frustrated digital video creators for not always displaying their videos to the people who subscribe to their channels and for sometimes pulling ads from their videos that people do see. So YouTube stars are increasingly responding by extending the lengths of their videos in order to curry favor with YouTube’s watch-time-minded recommendation algorithm and to be able to feature more ads per video.

“I’ve figured out ways to monetize and to take advantage of the power of the algorithm,” said Cody Ko, a comedian whose main YouTube channel claims more than 1.1 million subscribers. “Obviously, it preferences longer videos, throwing multiple mid-rolls in, which tons of people do now.” Last year, Ko typically posted videos to his channel that lasted between six and seven minutes. But as YouTube cracked down on which videos were eligible to carry ads and removed ads from some of Ko’s, he upped the average length of his videos to range from 12 to 16 minutes.

The move by creators to produce longer videos “is very much correlated to over the last two years when YouTube switched the recommendation engine and search and discovery [to push new channels and creators to viewers],” said Rafi Fine, CEO of Fine Brothers Entertainment, an entertainment company that produces videos and shows for digital platforms like YouTube as well as for traditional TV and whose main YouTube channel counts more than 17 million subscribers.

While YouTube’s algorithm has prioritized watch time since 2012, creators have seen it shift toward favoring videos that people are likely to click on, but from channels they don’t subscribe to over videos from subscribed channels, Fine said. But if creators can demonstrate that their audiences spend more time on YouTube in order to watch their longer videos, they may be able to retrain YouTube’s algorithm to promote their videos in order to generate the desired watch time.

Other creators and media companies are similarly lengthening the videos they upload to YouTube. Remi Cruz, a lifestyle vlogger with 2.3 million subscribers on YouTube, usually posts 20-minute videos, she said. Gwen Miller, vp of content strategy at digital video network Kin Community, said 10 to 16 minutes has become the sweet spot for YouTube videos. And Whistle Sports, a digital video network that works with individual creators and produces its own original programming, tries to stick between the seven- and 12-minute range.

“We’re trying to generate watch time because we know that’s favorable to YouTube,” said Josh Grunberg, Whistle Sports’ head of community development and growth. “We know that they want meaningful views.”

Meanwhile, the move to increasingly insert mid-roll ads within these longer videos coincides with YouTube’s push over the past year to more aggressively restrict ads from running against some videos in an effort to reduce its brand-safety problems. A video may still risk being stripped of ads, but creators can hedge their bets by attaching more ads to a video so that a monetized view can generate more money to offset a demonetized view.

Once Ko’s videos began to exceed 10 minutes, he could run multiple ads in the middle of videos in order to make more money per view. Sixty percent of viewers probably won’t even be shown an ad, said Ko, “but it ups the chance that someone will get an ad, so the [per-video revenue] goes up, and you make more money for your video.”

Ko’s shift to posting longer videos brought another benefit. “I find the retention is better for longer videos,” he said, attributing the correlation to the added time allowing for more jokes to be included.

Viewership retention underpins the trend toward longer videos and mid-roll ads. Without viewers willing to sit through longer videos, creators wouldn’t generate the watch time that YouTube’s algorithm looks for and wouldn’t have as many impressions for YouTube to serve ads. That’s leading more creators to increase the attention they put toward retention.

Earlier this year, Fine Brothers Entertainment took a harder look at its videos’ viewership retention analytics to take fuller advantage of the mid-roll ad option and increase the amount of money they make per video. Previously, the company would insert the ad around the seven- or eight-minute mark of an 11-minute video. It would do this for two reasons: It didn’t want to annoy any viewers that were also served a pre-roll ad, and it assumed people would stick around through the mid-roll, having seen most of the video, said Fine. But based on its videos’ retention rates, Fine Brothers Entertainment found that viewers were more likely to watch through an ad if it was inserted around the five- or six-minute mark.

“Everything inside that area [of viewership retention], that’s the No. 1 area right now on YouTube to be focused on,” said Fine.