It happens to us all. You’re out running, or just out for a walk. And all of a sudden you feel that flick, flick of a loose shoelace.

Now science can explain exactly why it happens. And, just maybe, offer a solution.

It’s simple physics, a team at the University of California Berkeley discovered.

“There is plenty of interaction between the swinging motion of your leg, causing the laces to whip forward, and also the impact on the ground. You actually need both,” said Christine Gregg, a graduate student who worked on the study.

A knot failure happens two ways: gradually, then suddenly. UC Berkeley

The laces are moving and then the thunk of your foot hitting the ground jars the knot.

“The impact force of the shoe during the striking of the heel is transmitted to the knot by the tongue of the shoe and the eyelets. As a result, the center of the knot deforms,” Gregg and her colleagues wrote in their report, published in the Proceedings of the Royal Society A.

It’s a gradual process, until it isn’t.

“The speed of the knot failure brings to mind a Hemingway line from ‘The Sun Also Rises’ describing a character’s descent into bankruptcy—which here we found to be an apropos description of knot failure—it happens ‘Two ways. Gradually, then suddenly’,” the team wrote.

Get the better newsletter. This site is protected by recaptcha

As a runner, Gregg had the problem frequently. “It would definitely be a problem. At least once on a run I would stop and retie them.”

And the professor whose lab she works in, Oliver O’Reilly, has a daughter whose shoes never stay tied, Gregg said.

As a mechanical engineer, Gregg felt it was an important problem to solve. So the team videotaped Gregg running with her shoes tied and analyzed the forces at work.

Related: How to Motivate Yourself to Work Out

Then they tried a mechanical pendulum to really pinpoint the movements involved.

“It might seem like a trivial problem, but the fact remains that we are trying to understand what fundamentally makes a knot strong,” said Gregg.

Why Some Knots Are Better

That has implications for surgery, aerospace engineering, even for parents of toddlers.

“When you talk about knotted structures, if you can start to understand the shoelace, then you can apply it to other things, like DNA or microstructures, that fail under dynamic forces,” said Christopher Daily-Diamond, the other graduate student who worked on the study.

“This is the first step toward understanding why certain knots are better than others, which no one has really done.”

Related: How a 'Might-Do' List can Help You Work Smarter

That’s not to say there isn’t a lot of knot science out there — there is. Websites will explain why granny knots are terrible and why a proper square knot not only looks better, but holds up better.

Gregg has made use of this new knowledge.

“There are many ways to solve this problem. If you are OK with double knotting, that’ll work,” she said.

She herself has learned to make a proper square knot instead of the twisted granny knot most people use to tie their shoes.

“I’ve been tying it a new way for about two years now,” she said.

It wasn’t easy to break old habits. “Muscle memory is both a blessing and a curse,” said Gregg.

“Every once in a while I find myself going back to my old habits. I remember the first time I did it, it took me a full two minutes to tie my shoe.”