When an emergency happens in the wilderness, quick thinking can often mean the difference between life and death.

After accidentally sliding down the face of a steep rock wall, two wayward tourists who recently found themselves stranded by the edge of a deep pool at the base of a thundering waterfall in British Columbia’s Golden Ears Provincial Park knew they were in a serious predicament.

Fortunately for them, five Sikh hikers who happened to be on the scene and witnessed their plight used not only their heads but also their hats—or more specifically, their turbans—to mount a pretty amazing rescue.

After taking stock of the situation, and with no cell phone service to call for outside assistance, the savvy group of international students struck on the idea of unwinding the long coils of their traditional headgear, and along with some added footage afforded by bits of their clothing, they managed to fashion a 33-foot lifeline with which they were eventually able to fish the stranded pair from their perilous perch.

“We were trying to think how we could get them out, but we didn’t know how to,” Kuljinder Kinda told NBC News. “So we walked for about 10 minutes to find help and then came up with the idea to tie our turbans together.”

Once the two anonymous (and no doubt embarrassed, since the waterfall hazard was clearly marked) hikers were pulled to safety, park officials stepped in to assess their condition.

As neither required medical treatment, they were released on their own recognizance—likely with a stern warning to better mind where they’re going next time.

Kinda and his four comrades, while more than pleased with their day’s work, were humble about their heroic exploits. It was simply a matter of being in the right place at the right time and having the means to help, they said.

“In Sikhi, we are taught to help someone in any way we can with anything we have,” Kinda told NBC, “even our turban[s].”

Our takeaway? When danger strikes and a rescue rope’s not handy, first think fast—and then think “knot.”