When relationships end, there’s a 50-50 chance it’ll end up being a clean break. Some of us choose to stay friends with our exes while others block them immediately. And then there are those of us who keep having sex with them after the fact. Why is that? And is it a good idea to keep a former relationship alive on some level? A new set of studies published in the journal Personality and Individual Differences offers some insight.

In the first study, researchers asked approximately 350 college-age adults to brainstorm potential reasons people stay friends with an ex by drawing on their own experiences. In total, participants generated more than 2,000 reasons, from which researchers extracted seven distinct themes:

  1. Reliability and sentimentality: “They were a great listener”; “I enjoyed their company”
  2. Pragmatism: “They would buy me nice gifts or food”; “I hoped to hook up with one or more of their friends”
  3. Continued romantic attraction: “I was still in love with them”; “I couldn’t imagine my life without them”
  4. Children and shared resources: “We had children together”; “We worked together professionally”
  5. Diminished romantic attraction: “I lost sexual interest in them”; “There were few negative feelings after the breakup”
  6. Social relationship maintenance: “To prevent awkwardness in our friend group”; “I wanted to stay friends with their friends”
  7. Sexual access: “The sex was good”

In the second study, researchers gave a different group of young adults (approximately 500) a list of reasons for staying friends with an ex that reflected these seven themes. They were asked to rate how important each one was and also completed personality scales, so researchers could see whether people’s personality traits predicted the reasons they endorsed.

What they found was that reliability/sentimentality was rated as the most important reason for maintaining a friendship, whereas pragmatism was viewed as the least important. Everything else fell somewhere in between.

While this overall pattern held for both men and women, differences between the sexes emerged. Specifically, men rated pragmatic and sexual access as more important than women rated them. In other words, guys seem to be more comfortable staying friends for selfish reasons.

People who scored high on personality traits linked to manipulative and deceitful behavior were also more likely to endorse pragmatic and sexual access as reasons for staying in touch. The traits we’re talking about here are part of the “dark triad,” a personality profile that involves having a malevolent nature. In general, men tend to have darker personalities than women, so this probably helps explain why guys were more likely to endorse selfish reasons.

People with personalities characterized by chronic anxiety and insecurity were more likely to endorse reliability and sentimentality. This makes sense because, for people who are anxious to begin with, keeping a former partner around—even if only as a friend—could be reassuring.

So is it a good idea to stay friends with an ex? Well, it depends on your motivations. If you’re doing it for selfish reasons, you might get what you want; however, if you lie to your ex about why you want to stay friends and they later discover the real reason, chances are they’re going to get hurt. So, not such a great idea.

However, if you’re doing it because you enjoy the company of your ex, or because you’re both invested in maintaining a positive relationship for the sake of a child, pet or your friends, that’s another story. As long as you’re both mature enough to handle the situation, it could end up being a win-win for everyone.

But what if you’re doing it because you have unresolved feelings for your ex? At least in the short term, there may be psychological benefits to keeping them in your life. Why? Because breakups leave us with some unfulfilled needs—and if you keep your ex around, you’re at least partially fulfilling those needs, which means the impact of the breakup won’t be quite as severe as it would be otherwise. Consistent with this idea, research has found that recently divorced couples who haven’t accepted the end of their marriage feel less distressed if they maintain a sexual relationship with their spouse.

However, these benefits might run out at some point, especially if maintaining a friendship or continuing to have “ex-sex” creates false hope that you’ll eventually get back together. If this drags out over a long period of time, this could prevent you from moving on and eventually make for a really messy ending.

In short, it’s neither an inherently good nor bad idea to stay friends with your ex. It all depends on your reasons. However, as long as you aren’t doing it for purely selfish reasons, your hopes aren’t unrealistically high for a romantic reunion and you’re both mature enough to handle the transition, by all means, keep the friendship alive.

Justin Lehmiller, PhD is a sex educator and researcher at Ball State University, a Faculty Affiliate of The Kinsey Institute, and author of the blog Sex and Psychology. Follow him on Twitter @JustinLehmiller.