If you’ve ever gone to the supermarket hungry, you’ve learned the hard way that it’s a mistake. Chips? Yes, please. Chocolate-covered pretzels? Why not? The solution: Eat a pre-shopping snack.

But not just any snack. According to a series of three studies from the Cornell University Food and Brand Lab, how you fill up before heading to the supermarket also affects how healthy or unhealthy your shopping trip becomes. In fact, in the first study, when researchers tracked the food purchases of 120 supermarket shoppers, they found that those who received and ate an apple sample before shopping ended up buying 28 percent more fruits and vegetables than those who received a cookie sample, and 25 percent more fruits and vegetables than those who received nothing to snack on.

What’s more, in the second experiment, researchers gave a group of 56 participants either an apple or cookie sample, and then presented them with 20 pairs of food. Each pair contained one healthy food and one unhealthy food. When asked to choose which foods they wanted, the apple-eaters selected the healthy option two-thirds of the time, while the cookie-snackers chose the unhealthy option more than half of the time.

Why do apples beget more apples … and pears and quinoa and salmon? Because if you’re eating an apple, you probably have apples on the brain. And along with them, other healthy foods, says lead study author Aner Tal, a research associate in the Food and Brand Lab.

“Called priming, this is a well-known psychological phenomenon, but until now it hasn’t really been extended to healthy eating behaviors,” explains Kathleen Ashton, a psychologist with the Bariatric and Metabolic Institute at the Cleveland Clinic, who was not involved in the research. “It’s often used in marketing. For example, if I give you a list of words like ‘beach,’ ‘waves’ and ‘surf,’ what laundry detergent are you thinking of? Probably Tide. If I give you a list of words like ‘happy’ and ‘fun,’ you’ll likely think of Cheer.”

The same thing happens in your brain when you eat any healthy food, Tal says. Or any food you think is healthy. In the third study, the researchers labeled identical glasses of chocolate milk as either “healthy” and “wholesome” or “rich” and “indulgent.” Those who drank the so-called healthy milk selected more healthy options from a virtual grocery store than those who drank the supposedly indulgent one. “The more strongly you associate the food with health, the more likely it is to work at priming you to make healthy food purchases,” Tal says.

And, provided you eat your healthy purchases once you get them home, you could see improvements in health measures such as body mass index, blood pressure and disease risk, says Melissa Rifkin, a bariatric dietitian at the Montefiore Medical Center in New York City. For instance, simply eating more produce – after all, apple-snackers bought 28 percent more of it than did cookie-snackers – can dramatically cut your risk of chronic disease and premature death. In a recent study published in the Journal of Epidemiology and Community Health, subjects who ate at least seven servings of fruit and vegetables per day had a 42 percent lower risk of dying from any cause than those who ate less than one full serving per day.

Prime Yourself for Healthy Eating

The obvious take-home message is that you should eat a healthy snack before heading to the supermarket. Rifkin recommends opting for a fiber- and water-rich piece of fruit or some snackable veggies such as carrots or celery. Both the fiber and water will help keep you full and your blood sugar stable so your sugar levels don’t crash while you’re walking past the candy aisle, she says.

Also, it’s probably wise to choose a pre-supermarket snack you actually like. Otherwise, by force-feeding yourself a healthy food you hate, you might end up turning yourself off of healthy food altogether, Tal says. Meanwhile, you can also prime yourself for healthy supermarket decisions simply by writing out and bringing a healthy shopping list, according to Rifkin. You’ll have to glance at it during your trip to make sure you’re getting everything you need, and each time you look at the list of healthy foods, you’ll prime yourself to keep your resolve.