It might not come as a shock to learn that stress can turn your hair gray, but a team of Harvard scientists recently discovered the surprising reason why.

Scientists have long understood that gray hair is the result of the natural aging process, certain pigment/follicle disorders, and stress. But until now, we’ve never known exactly what role stress plays in causing gray hair. Previous theories have insisted that stress somehow accelerates the aging process or triggers an autoimmune response.

Read: Scientists working with Google just published the most detailed brain scans ever created

But, as it turns out, the specific type of stress associated with the brain’s fight-or-flight response is the culprit behind graying. When we experience this type of stress it causes a sympathetic nerve response that activates the stem cells responsible for coloring our hair. Basically: we use up the limited supply of hair dye in our cellular make-up if we get too scared.

According to the Harvard team’s research paper:

Our study demonstrates that neuronal activity that is induced by acute stress can drive a rapid and permanent loss of somatic stem cells, and illustrates an example in which the maintenance of somatic stem cells is directly influenced by the overall physiological state of the organism.

How’d they figure this all out? Well, that part’s actually a bit gruesome. They put laboratory mice under three different types of stress: physical restraint, physical pain, and psychological distress. Each stressor caused the mice to develop gray/white hair.

The researchers then began troubleshooting to see what was actually causing the grayness. Suspecting adrenal glands were the cause, they ran the tests again on mice with theirs removed. Those mice still experienced graying, so they tried again with other hormonal processes inhibited. Eventually, the researchers discerned that a sympathetic nervous response was causing the stem cell overload responsible for the gray hairs. Once they blocked that response, the mice stopped going gray.

A pair of researchers not involved with the study opined that the appearance of gray hair in animals who’ve experienced fight-or-flight stressors could indicate an evolutionary advantage:

It is fascinating to consider what possible evolutionary advantage might be conferred by stress-induced graying. Because grey hair is most often linked to age, it could be associated with experience, leadership and trust… Perhaps an animal that has endured enough stress to ‘earn’ grey hair has a higher place in the social order than would ordinarily be conferred by that individual’s age.

Read the full study here on Nature.