It’s a dreadful feeling wondering where your life is going, regardless of your age. Stagnation not only makes us question what’s next, but it also fosters thoughts that there won’t be a way out. So it makes sense that having goals and working toward them — a sense of purpose, some might say — improves a person’s chances of living longer, according to a new study.

“Our findings point to the fact that finding a direction for life, and setting overarching goals for what you want to achieve can help you actually live longer, regardless of when you find your purpose,” Patrick Hill, lead research of the study from Carleton University in Canada, said in a press release. “So the earlier someone comes to a direction for life, the earlier these protective effects may be able to occur.”

Ultimately, it comes down to the benefits of having a positive outlook on life. People who have goals and work toward them are probably going to feel more self-worth, thus improving their positivity. This creates an upward spiral of positive feedback. That’s regardless of whether it’s going out with friends to spend some time together or working hard at your job — either way, it’s fulfilling.

The researchers discovered this after looking at data from 6,000 adult participants in the Midlife in the United States study. They looked at the participants’ self-reported responses to statements about their own purposes in life, such as “Some people wander aimlessly through life, but I am not one of them,” as well as other variables that measured their personal relations to others, and positive and negative emotions.

Fourteen years later, they found that 569 participants, or about nine percent of the sample, had died. These participants were also the most likely to report having little to no purpose in life and fewer positive relations. On the other hand, those who reported the opposite lived longer, regardless of whether they were younger, middle-aged, or older.

“There are a lot of reasons to believe that being purposeful might help protect older adults more so than younger ones,” Hill said in the release. “For instance, adults might need a sense of direction more, after they have left the workplace and lost that source for organizing their daily events.” Older adults also face more risk of dying, such as heart disease or diabetes. “To show that purpose predicts longer lives for younger and older adults alike is pretty interesting, and underscores the power of the construct,” he added.

Source: Hill P, Turiano N. Purpose in Life as a Predictor of Mortality Across Adulthood. Psychological Science. 2014.