Perseverance, or the ability to stick with something, is critical to success in life, from academics and sports to music and getting around to that presentation for tomorrow’s meeting.

But life is increasingly distracting, especially for kids, with the allure of technology and the ability to access just about any form of entertainment on demand.

So what gives a child grit? Six researchers, building on past studies, designed an experiment to see what makes kids stay on task when presented with the very real-world temptation of an iPad.

Rachel E. White, from Hamilton College, and Emily Prager and Catherine Schaefer from the University of Minnesota, tested four and six-years-olds by giving them a boring computer task and asking them to do it for 10 minutes. They also offered the kids an out: If they got bored, they could play a game on the iPad, located nearby in the testing room.

Could kids actually resist the temptation?

There was a twist. The 180 kids were assigned to one of three conditions: a control group, which asked the children to think about their thoughts and feelings as they went through the task and ask themselves “Am I working hard?” The second group was asked to think of themselves in the third-person, for example (if the kid’s name is Hannah), “Is Hannah working hard?”

In the third condition, the kids were asked to think about someone else who is really good at working hard. They could pick from some well-known superhero types: Batman, Bob the Builder, Rapunzel, and Dora the Explorer. The kids got to dress up as the character they picked and then were asked, “Is Batman working hard?”

For 10 minutes the kids could move between the “work” and iPad. They were reminded every minute, through a loud speaker, of their “condition” (“Is Dora working hard?”). All the kids were told, “This is a very important activity and it would be helpful if you worked hard on this for as long as you could.” Perseverance was measured as time spent on the ‘work’ task.

Not surprisingly to anyone who has kids, and iPads, the kids spent 37% of their time on the ‘work’ task, and 63% on the iPad.

But those kids pretending to be superheroes ‘worked’ more than those who thought of themselves in the third person, and both of those groups did better than the kids who just thought of themselves as ‘me’.

In other words, the more the child could distance him or herself from the temptation, the better the focus. “Children who were asked to reflect on the task as if they were another person were less likely to indulge in immediate gratification and more likely to work toward a relatively long-term goal,” the authors wrote in the study called “The “Batman Effect”: Improving Perseverance in Young Children,” published in Child Development.

This is not a new finding. In the 1960s, Walter Mischel’s did his famous marshmallow test at the Bing nursery school at Stanford which cleverly put kids roughly 3.5 to 5 years old in a room with a treat (marshmallows were one) and told them they could eat it, or wait, and get two. Those kids who were able to delay their gratification, or who exhibited high levels of self control fared far better in life; they did better academically, earned more money, and turned out to be healthier and happier. They were less likely than those who could not resist to be obese, do drugs or go to jail.

The key to superior executive function, or self-control, Mischel and Patterson concluded, was the ability to reframe the object of temptation into something more abstract. One boy told Mishel he imagined the marshmallow was a picture and not a treat, according to this New Yorker profile. “You can’t eat a picture.” The secret to reframing is learning how to mentally “cool” the “hot” aspects of an environment which tempt you. Maria Konnikova, explains it this way in the New Yorker:

“Cooling can be accomplished by putting the object at an imaginary distance (a photograph isn’t a treat), or by re-framing it (picturing marshmallows as clouds not candy). Focussing on a completely unrelated experience can also work, as can any technique that successfully switches your attention.” — Maria Konnikova

Donning a cape and mask, the kids from the recent study were better at what psychologists call ‘self-distancing’. One reason the kids engaged in imaginary play had better focus might be that pretending to be another person allowed the greatest separation from the temptation. A second potential explanation is that the kids in costume identified with the powerful character traits of the superhero and wanted to imitate them. Whatever the cause, the superheroes showed more grit.