A beach on Georgia’s St. Simons Island became the scene of a dramatic rescue operation on Tuesday, after as many as 50 pilot whales swam into perilously shallow waters. Beachgoers who had been enjoying the sunny day sprang into action, dousing the pilot whales with water and pushing them deeper into the sea, despite shark sightings in the area.

According to Sarah Emerson of Vice, at least a dozen of the animals repeatedly beached themselves. Dixie McCoy, who was on the scene that day, recorded part of the ordeal on Facebook Live. Her video shows the whales writhing in the sand, making high-pitched vocalizations, as volunteers rushed to pour water over them with cupped hands.

“They’re going to die if they don’t get help,” McCoy says in the clip.

Experts with the Georgia Department of Natural Resources, the National Oceanic and Atmospheric Administration and the Georgia Sea Turtle Center were on the scene to orchestrate the rescue—which was no easy feat, considering that a single adult pilot whale can weigh between 1.5 and three tons. The effort to get the creatures into deeper waters took hours; ultimately, though, almost all made it back to the sea alive. Three whales, in total, died, one of whom had to be euthanized, according to Emily S. Rueb of the New York Times.

Mass whale strandings happen around the world and can involve anywhere from two to several hundred individuals. In 1918, for instance, 1,000 pilot whales stranded themselves on New Zealand’s Chatham Islands.

Scientists are not entirely certain why these tragic events occur. Geography might be one factor at play; according to Whale and Dolphin Conservation, cetaceans are more likely to beach on shallow, sloping shores made of soft sediment, which can interfere with the echolocation that whales use to navigate. High-level sonar, of the sort emitted by naval activities, causes whales to swim rapidly away from the sound and leads to strandings. Even disruptions in Earth’s magnetic fields might bungle whales’ sense of navigation. According to the National Oceanic and Atmospheric Administration, many whales have been shown to have crystals of magnetite, an iron-oxide mineral, in their brains, which some experts believe help them sense the Earth’s magnetic field. Events like solar storms, which impact the magnetic field, could therefore cause cetaceans to lose their way. Injuries, infections and old age can also prompt some whales to seek out shallower waters, where it is easier to breathe.

Toothed whales that live in tightly knit social groups—like pilot whales—are most likely to be involved in mass strandings. This seems to stem from “persistence to keep the group together,” according to the American Cetacean Society—which is to say that if one whale gets injured or becomes sick, other members of the pod might follow it into shallow waters. Emerson reports for Vice that in the case of the Georgia whales, a large group of pod members hovered around 300 miles from the shore. Rescue workers tried to maneuver them to face away from the beach, in the hope of encouraging them to swim out to sea. But some of the whales did not seem to want to leave.

“We can’t really speculate in this specific case, because we haven’t done the necropsy, or animal autopsy on these animals yet, so we don’t know the cause of death,” Clay George, a senior wildlife biologist with the Georgia Department of Natural Resources, told reporters. “But in other cases in other states, the experience is that often there will be one or more sick individuals that it appears the other animals have followed in.”

“This is exceedingly rare for something like this to happen in Georgia,” George added. “These animals should be 100 miles or more off our coast, out off the edge of the continental shelf. And so something went wrong with this pod of pilot whales, days or maybe even weeks ago.”

Officials hope that necropsies of the dead cetaceans will provide some answers; the investigation could reveal signs of plastic ingestion, sonar disturbances and other factors that might have led the animals astray. For now, experts are trying to keep a close eye on the pod. On Wednesday morning, boat pilots spotted the whales, and as of yesterday afternoon, they had moved further offshore. Further strandings are still possible for the pod, according to the Georgia Department of Natural Resources, but George says he is “cautiously optimistic” that the threat has passed.