Taking great selfies really is a science.

Researchers have created a formula for getting the most flattering snap, which they’ve developed into a smartphone app.

Computer scientists at the University of Waterloo made 3D models of “average” looking people, and then took hundreds of “virtual selfies” by writing code to control a virtual smartphone’s camera and computer-generated lighting. It also played with different face sizes and angles, lighting directions and other composition factors that you manipulate when trying to put your best face forward in a pic.

Then the team crowdsourced thousands of people to vote online for which of the virtual selfies looked the best, and the researchers crunched all of that data to create an algorithm to guide you in taking the best possible picture of yourself. And when they had real people take selfies using both a standard camera app and an app guided by Waterloo’s picture-perfect formula, the people using the algorithm-backed app saw a 26% improvement in their selfies.

See also: You can now earn a college degree in social media stardom

“Unlike other apps that enhance a photo after you take it, this system gives direction, meaning the user is actually learning why their photo will be better,” said Dan Vogel, a professor of computer science at Waterloo, in his report. “This is just the beginning of what is possible. We can expand the variables to include variables aspects such as hairstyle, types of smile or even the outfit you wear.

“When it comes to teaching people to take better selfies, the sky’s the limit,” he added.

And so are the potential profits, thanks to our selfie-obsessed society. The global selfie stick market alone – necessary for getting those flattering overhead angles, and at a greater distance than just arm’s length – is set to grow 26% between 2016 and 2020, when it will hit $174.1 million, according to Technivo analysts. Being an internet influencer is a $10.8 billion industry in China thanks to its 700 million smartphone users, and that is expected to double by 2018. And just one social media post from Beyonce is worth $1 million in advertising.

But a Waterloo University rep told Moneyish that the researchers haven’t decided whether to sell their app to consumers just yet. “It was developed purely for research, to show it’s possible to have a camera show people how to take the perfect selfie,” he said.