Habits are tough to break. Whether it’s a decade-long smoking habit or pessimistic thought patterns, when the things we do, say, and think are second nature to us, it takes time and effort to break the habit and move on to a healthier way of living.

So, why is it, after months (or years) of hard work put into leaving a habit behind, we revert so quickly to old ways in the presence of old friends or family? Maybe it’s a trip home that serves as the catalyst for picking up smoking again, or a night out with old college roommates that brings an ugly gossiping habit back to the surface—it’s frustrating to realize habits from the past are so easy to slip back into (and feel so comfortable when we do).

The answer is simple, but not so simple to fix: it all comes down to factors that serve as triggers for behaviors, especially our environment. The formation of habits is a process that is etched into our neural pathways, according to Kristina Orlova, licensed marriage and family therapist. Habitual behaviors can be triggered by a number of things, such as your environment, if you are feeling stressed, and how well-rested you are.

“A person has a behavioral response,” says Orlova. “If it is a habit it is often an unconscious, routine response like when going back home to visit parents and friends.”

Another theory is that when we’re with old friends, survival drives us to fall back into old ways of doing things, according to life coach Dr. Diana Robinson, who points to the very essence of the theory of evolution: those most able to adapt to change survive.

“The people we are with form the context and adaptation to the situational context is … important for survival,” Robinson explains. “We all like to think that we are independent in our behavior, but we often do not recognize how much we adapt in different contexts.”

Frequently, we adapt using habits we can trust because we have already tried them out within a given context. We have interacted with old friends and family frequently enough in the past and we know how they will behave and the best ways for us to respond.

If we have changed significantly since our last interaction, the desire for acceptance may drive us to be the person they expect us to be. Whether we fear making others uncomfortable by changing or we simply worry we won’t be accepted, our desire to belong is a powerful force that can influence our decision making, according to Robinson.

So, with a visit around the corner, is it possible to prepare for the temptation to cozy up with old habits that feel comfortable and safe? What is the best approach when you want to feel you fit in your old environment but you don’t want to use unhealthy habits to accomplish a feeling of belonging?

Preparing yourself can be key to enjoying time with old friends or family without feeling obliged to be the same person you were in the past. By being mindful of who you want to be now and how your behaviors play a role in your identity, you can actually rehearse for circumstances that may tempt you to return to old habits.

“If behaving as the same old [person] that they are accustomed to is not the person you now are, then prepare yourself with some responses,” Robinson advises. “It is much easier to say something that we have said a number of times before, so actually ‘rehearsing’ in front of a mirror what you might say makes more sense than we might expect.”

Another tool is to recognize the things that trigger you and think about how to respond.

“Once you can identify your own pattern of thoughts, emotions, behaviors, you can slow the process down and see where perhaps you are having an irrational thought,” Robinson says. “[The] next step would be to replace the irrational automatic thoughts with a more accurate or neutral thought that will lead to lower emotional triggers and perhaps even a calm emotional response which will affect behavior.”

Mindfulness and meditation can play an important role in your preparation, allowing you to train yourself to be centered and self-aware, which are crucial skills when walking into situations that may be challenging or make you feel anxious.

“Mindfulness and meditation have been shown to have lasting impact on helping a person to stay calm and relaxed,” explains Orlova, “When facing a potential trigger of being in an old environment with family and friends, being able to activate that inner part of yourself and remind yourself to let go of whatever is happening will absolutely help you cope and move through what can be a challenging experience with more compassion for yourself and for those around you.”

The author of this post is an editorial contributor to Headspace. These are their views, experiences and results and theirs alone. This contributor was paid for their writing.