The classic self-control experiment known as the Marshmallow Test is elegant in its simplicity. The young child who is able to resist eating the single marshmallow before him and wait instead for the promised two marshmallows is deemed to have better impulse control and ability to delay gratification than the child who succumbs to the single marshmallow’s charms and thus loses the chance to double his serving of sweets.

But a study published online Oct. 11 in the journal Cognition paints a more complex picture: Kids’ reaction to the single/double marshmallow challenge may not derive solely from their innate ability to resist temptation but also from their quite rational and astute assessment of the reliability of the environment they’re in and the people they’re dealing with.

The authors explain why this matters:

Waiting is only the rational choice if you believe that a second marshmallow is likely to actually appear after a reasonably short delay — and that the marshmallow currently in your possession is not at risk of being taken away. This presumption may not apply equally to all children. Consider the mindset of a 4-year-old living in a crowded shelter, surrounded by older children with little adult supervision. For a child accustomed to stolen possessions and broken promises, the only guaranteed treats are the ones you’ve already swallowed. At the other extreme, consider the mindset of an only child in a stable home whose parents reliably promise and deliver small motivational treats for good behavior. From this child’s perspective, the rare injustice of a stolen object or broken promise may be so startlingly unfamiliar that it prompts an outburst of tears.

To test this notion, researchers at the University of Rochester in New York assembled 28 kids ages 3 to 5 years and divided them into two groups, one to be subjected to the “reliability” condition and the other to the “unreliability” condition. The children were tested individually, with researchers and parents observing while out of the kids’ view.

Children in the unreliability group got a raw deal. Presented with a crummy jar of stubby, used crayons to work on a craft project with, they were promised access to a fancy set of art supplies if they could wait until the researcher came back to the room. The crayon jar was deliberately closed tight and placed in the center of the table where it was hard to reach; the researchers wanted the kids not to opt to use them because they needed a second interaction to transpire. That worked; none of the kids used the crayons. In the second interaction, the researcher came back without new art supplies and said, I’m sorry, I was wrong. You have to use these crayons after all.

When the children were coloring, they were presented with an unappealing little sticker, also for use in their craft project. Again, they had a choice: Use this dumb thing or wait for the researcher to come back with fancy stickers. Again, the researcher came back without fancy stickers.

So it’s not surprising, given the obvious unreliability of the researcher, that the kids in this group were quick to grab the single marshmallow. All but one of them ate the marshmallow before the researcher returned, and they waited only an average of three minutes before doing so.

Meanwhile, over in the happy land of the “reliable” group, the fancy art supplies and stickers were delivered as promised. When it came time for marshmallows, nine of the 14 kids waited the full 15 minutes and were rewarded with a second marshmallow. On average, kids in this group waited 12 minutes before succumbing.

In the classic Marshmallow Test, kids typically last an average of about six minutes before eating the marshmallow. In a child’s universe, the difference between waiting three minutes, six minutes and 12 minutes is enormous.

The authors note that their work demonstrates that the ability to delay gratification is affected by both innate self-control and assessment of the reliability of the environment. “If deficiencies in self-control caused children to eat treats early,” they write, “then one would expect such deficiencies to be present in the reliable condition as well as in the unreliable condition.”

The Marshmallow Test has been in use for about 40 years and has been found to be a predictor of success in childhood and later in life, the study explains.  Parents of kids who hold off for the second marshmallow report their children have better self control and interpersonal skills than those who eat the single marshmallow, research has shown, and adolescents who held out for the second marshmallow as children have been shown to have better SAT scores and are less likely to engage in substance abuse than those who ate the single treat.

You can watch a video of the experiment here. Not to worry: All the kids got extra marshmallows –plus little treat bags and $10 – in the end.