Humans have been eating our emotions for as long as we can remember. But that doesn’t make it a good idea. There’s a science behind emotional eating and comfort food ― the factors that cause cravings and the ways that giving in to those cravings affects us.

The big three hormones: cortisol, dopamine and serotonin.

Cortisol is our main stress hormone, triggering our fight-or-flight instinct. It also regulates how our bodies use carbohydrates, fats and proteins. So if we’re stressed or anxious and cortisol kicks in, that can make us want to carbo-load.

Then there’s dopamine, a neurotransmitter associated with learning about rewards. It kicks into gear at the promise that something positive is about to happen, like eating a food you love. The comfort foods we turn to because they taste so good give us a surge of dopamine, Albers said, and we look for that high again and again.

“There’s research that says even anticipating eating certain foods generates dopamine,” said Karen R. Koenig, a licensed clinical social worker, eating psychology expert, blogger and author. That explains why scientists call it “the anticipation molecule” ― it’s released when we know we’re about to experience something pleasurable. “You don’t even have to be eating [to generate dopamine],” Koenig told HuffPost.

And let’s not forget serotonin, aka “the happy chemical,” which when it drops to low levels can be linked to depression. A hormone and neurotransmitter, serotonin itself isn’t in food ― but tryptophan, an amino acid necessary to produce serotonin, is. Famously associated with turkey, tryptophan is also found in cheese, and that could be why Thanksgiving drumsticks and grilled cheese sandwiches are a comfort. Carbs can also boost serotonin levels, which can improve your mood, and chocolate, too, is linked to a serotonin spike.

Eating can be a convenient distraction from emotions.

Sarah Allen, a psychologist specializing in mood and eating disorders, lists stress and boredom as two main drivers of emotional eating. And that’s because eating is a task.

“Eating gives us something to do. It fills our time, gives us a way to procrastinate,” Albers told HuffPost.

We often use eating to mark time — lunch, for instance, can provide a break in a dragging work day. So we come to associate eating with relief or even excitement, and it’s only natural that we’d reach for those same feelings when we’re worried or sad.

“Events don’t have a meaning; we give them a meaning,” Koenig said. “The meaning of eating is, ‘I’m going to be happy. I’m not going to be in emotional discomfort. I’ll have this wonderful experience.’”

This connection is also relevant when it comes to another kind of emotional eating: happy eating. Think about how you celebrate big achievements and special occasions, or even just define fun outings. We treat ourselves to our favorite foods to define a moment of pride or joy, and we link activities like going to a movie with getting to indulge in candy.

We choose the familiar discomfort of food over the unfamiliar discomfort of feelings.

“There’s conscious and unconscious emotional discomfort,” Koenig said. “Sometimes we know [what we’re feeling], sometimes we don’t — we just feel uneasy or not happy, and we don’t deal with that. Instead, we just eat. Then we get what we know we’ll have: shame, remorse, regret. ... We trade in the first discomfort, which is maybe unfamiliar and something we’re more frightened of, for the familiar feelings that come after emotional eating.”

Comfort foods don’t tend to be healthy. We want cake or pasta or chips when we’re emotionally eating. There are a few reasons for this, according to Albers: We have emotional memories around certain foods, which are more likely to involve your grandma’s lasagna than a salad. Plus, our culture categorizes certain foods as treats or guilty pleasures, and that’s what we want to soothe or reward ourselves. Furthermore, something like a candy bar gives your blood sugar a surge, which makes you feel better in the moment.

But after we eat for emotional reasons, we may not feel too great ― because we know we overate or consumed unhealthy foods. Or maybe we feel just fine ― because we’re celebrating a hard-earned promotion with a red velvet cupcake. Either way, we’re replacing our original feelings with the emotions that arise out of eating, from shame to satisfaction.

We associate comfort food with positive memories.

Troisi worked on a 2015 study conducted for the journal Appetite by a State University of New York at Buffalo research team. The study involved a group of undergraduate students, some of whom were asked to remember a time when one of their close relationships was threatened or they felt alienated in some way. Afterward, those who recalled feelings of isolation or loneliness were more likely to consume comfort foods, Troisi said, and they found those foods to be tastier than did other students who were not eating the comfort foods in an emotionally negative situation.

“We’re working with the assumption that individuals ... consume comfort foods when they feel isolation because it reminds them of the strong relationships they do or did have, and that can alleviate that isolation,” Troisi said.

Think about all the happy and comforting memories you have involving food. Maybe your family used to celebrate occasions with a trip to the ice cream shop, or maybe your mom or dad used to soften the blow of a bad day with macaroni and cheese. When you’re feeling rejected or anxious today, eating one of those foods is an instant connection to that soothing time.

Here’s how experts suggest you control emotional eating.

All of the experts we spoke with said that emotional eating can be OK in moderation. But when this behavior becomes a habit, that can harm you both physically and emotionally — physically, because of the regular consumption (and perhaps overconsumption) of foods that aren’t so healthy, and emotionally, because, as Albers noted, eating to avoid facing feelings is like putting a “Bandaid on a broken arm.”

So how do we separate our emotions from eating? To start with, we have to remember food’s true purpose ― to nourish us. In fact, Koenig suggests that the term “comfort food” itself could be part of the problem.

“A misleading misnomer if there ever was one, comfort is not something we want to keep associating with food,” Koenig said. “We want to file food in our brains under nourishment and occasional pleasure. We want to seek comfort through friends, doing kind things for ourselves and engaging in healthy activities that reduce internal distress.”

“As soon as you start looking for food, stop,” Allen advised. “Think, ‘Am I hungry? Do I need food in my stomach, or is one of my triggers going off? What do I need right now?’”

Both Albers and Koenig said that we should ask ourselves if we’re actually hungry for food or if we need some other action to treat what we’re feeling. Allen suggests journaling, even if it’s just quickly jotting down what you’re eating when and taping that note to the fridge, in order to recognize a pattern in what you eat, when you eat it and why. Koenig recommends thinking of a flow chart: Am I hungry ― yes or no? What do I want to eat? Am I not hungry? What I am feeling? If you’re grieving, think of constructive ways to sit with that grief. If you’re angry or hurt by someone, go talk to that person.

Albers and Koenig also pinpoint the concept of mindful eating. Eating should be its own activity. Instead of mood-driven consumption, we should be solving our emotional needs on their own and concentrating on our meals on their own. What good is even the most delicious treat if you’re so emotionally distracted that you’re just eating and eating to the point where you can’t even taste it anymore, and you’ve ignored the signs of fullness to the point of discomfort? When we eat, the goal is to sit down and really experience that meal and its flavors, and be aware of when we’re full.

One important thing to remember if you’re trying to curb emotional eating habits is not to go cold turkey: Don’t give up on every single food habit at once, don’t beat yourself up about the times you do eat your feelings and do think about other forms of comfort and reward.

“When you tell yourself you can’t have something, then you want that thing,” Allen said. “If you say you can’t have chocolate, you think of chocolate.”

The risk of being too hard on ourselves is that it only increases feelings of stress, longing, shame and guilt, all of which can just lead to a vicious cycle. We can enjoy our cookies every now and then, but we should try to eat them for the pleasure of eating a cookie and not as a form of self-therapy.