In mid-July, I was visiting my hometown in Minnesota when I happened upon the unmistakable scent of something deep-fried. I was at a concert, and no matter how off-brand a dietary choice of corn dogs and cheese curds may be for a health writer, I went for it. How could I not? I spent two thoroughly enjoyable summers during college working at the Minnesota State Fair, and that experience continues to make corn-and-grease-dipped hot dogs not only appetizing but somehow irresistible, too.

Summer is the season for nostalgic eating: Hot days in the park call for a trip to the ice cream truck, concerts call for corn dogs, baseball games call for hotdogs and beer, ice-cold movie theaters call for popcorn. And it’s not just me. Researchers suggest that when we associate foods with happy memories, the effects are profound, impacting how good we think foods taste as well as how good those foods make us feel.

It makes intuitive sense that positive experiences with a given food could influence our craving for it later on, but recent research also suggests something else is at play, too: comfort foods remind us of our social ties, which means they may help us feel less lonesome when we feel isolated. In a recent July 2015 study, Jordan Troisi, an assistant professor of psychology at Sewanee, The University of The South, and his colleagues found that people with strong relationships preferred the taste of comfort food when they experienced feelings of social isolation.

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

“Comfort food seems to be something people associate very significantly with close relationships,” says Troisi. “This probably comes about by individuals coming to associate a particular food item with members of their family, social gatherings, and people taking care of them, which is why we see a lot of comfort foods [that are] traditional meals or things had at a party.”

Of course, what counts as comfort food is different person to person. When Troisi has asked people write about an experience they’ve had with a comfort food, essays have ranged from soup to kimchi. “It’s not just that ice cream, for instance, is really tasty. It’s that someone has developed a really significant meaning behind the idea of ice cream due to their relationships with others, and that’s what is triggering this effect,” he says.

Even the smell of a meaningful dish can elicit feelings of belonging, some research suggests. In a February 2015 study, Virginia Commonwealth University researcher Chelsea Reid and her colleagues had 160 people smell 12 different scents, including apple pie, cotton candy and baby powder and rate the extent to which the scent was familiar, arousing, autobiographically relevant, and the extent to which it elicited nostalgia. “Nostalgia can be evoked in different ways, but scents may be particularly likely to evoke nostalgia due to the strong link between scents and memory. The smell of pumpkin pie might bring all those holidays with family flooding back, or the smell of a familiar perfume might arouse memories with your partner,” says Reid.

Biologically speaking, scent and memory are closely tied. “Psychological research has demonstrated that smells are powerfully linked to memory, and to autobiographical memory in particular,” says Reid. “The olfactory bulb, which is involved in the sense of smell, is linked to areas in the brain associated with memory and emotional experiences.”

Humans have a fundamental need to belong, says Reid, and because nostalgia often centers around personal events involving people they care about, she sees the evocation of nostalgia as one way people can obtain a sense of belonging even when the people they are close to are not close by.

So while corn dogs in the summer may not be fine dining by any standard, for me, they trigger happy memories of summers long ago—and that’s a good thing. In moderation, of course.

Read next: 5 Foods That Taste Better Now Than They Will All Year

Listen to the most important stories of the day

Contact us at letters@time.com.