It’s a dog owner’s worst nightmare: You take your very good pooch to the lake for a swim. Maybe you crack a cold one while you throw the ball for Fluffy. An hour later, soaked and happy, you head home. But en route, your pup suddenly becomes exceptionally ill. Hours later, they’ve passed away.

A woman in North Carolina lost three dogs after they went swimming in a pond this summer. And experts have been warning dog owners in other states, from Washington to Texas, that toxic algae might be lurking in their local waters. The problem is cyanobacteria, or blue-green algae, which can be highly toxic to animals of all kinds. But a researcher at the University of Maryland thinks there may a promising tool in helping beat back these blooms—and it’s associated with that beer you drank while playing fetch.

First, some background. If it seems like toxic algae problems are getting worse, you’re right. A new paper published in October in Nature looked at historical satellite images from 70 lakes across the globe to see if the problem is expanding or if blooms are just getting more more media attention. The trend is definitely going the wrong way, says Anna M. Michalak, one of the coauthors of the study and a professor at Stanford’s Carnegie Institution for Science. “The only lakes getting better are lakes that are warming less or even cooling, so this strongly suggests there are links to climate change,” she explains.

Algae love warm water. They also love nutrients, like the nitrogen and phosphorous used in industrial agriculture or from poorly managed human sewage. Climate change may bring more intense rain events, which will help move those nutrients from farm fields into lakes and ponds, says Michalak.

To be clear: the best way to save our pups and ourselves is to get serious about combating global climate change. We also need to do better at controlling runoff and raising water-quality standards. While we tackle those two giant issues, though, a researcher at the University of Maryland is looking where we often look when trying to solve a problem: beer.

Taylor Armstrong, a Ph.D. student at the University of Maryland’s Center for Environmental Science, and her professor, Al Place, have been examining whether barley straw can prevent algal blooms when added to small ponds. “When barley degrades, it releases these compounds that inhibit some species of algae,” Armstrong explains. There’s quite a bit of research showing the promise of barley straw in controlling certain types of algae—especially the bad stuff. They’ll throw whole bales into the water, sometimes attached to rods or ropes so it stays in one place. As the straw breaks down, it releases phenolic acids and flavonoids, organic compounds that inhibit the growth of algae.

However, “you have to put it out months ahead of when the algal bloom might happen,” says Armstrong, since it takes a long time for the straw to start breaking down. Armstrong wondered if there might be another barley product that wouldn’t take so long degrade. Which is when she thought of all the barley that goes into beer.

Spent grain—the leftovers after brewers extract sugars needed to make beer—is “the number-one waste product of breweries,” says Armstrong, so there’s a lot of it available, and many brewers give it away for free. Plus, brewers make their beer with barley hulls, which have more phenolic acids and flavonoids than are found in barley straw. Best of all, during the brewing process, the barley begins to degrade. This could mean a much shorter lead time than the weeks or months required of barley straw.

Sounds perfect, right? It is, of course, not that simple. “Do not immediately go out and throw spent grain in your water because of this. The research is still in its infancy, and anything you do could impact the ecosystem,” Armstrong warns. Any time you add nutrients to a body of water, you could be triggering more algae growth, she says, noting that previous studies have shown that too much barley straw in a waterway can backfire. So can adding too little. It’s like Goldilocks: you have to get it just right.

Which is why Armstrong is still testing her hypothesis in a lab. So far the results are promising. The spent grains seem to inhibit the growth of sinister algae. She’s using spent grain from a pilsner made at her local Diamondback Brewing Company, which is more than happy to give it away. “I just used the Contact Us page on their website, and they said, ‘Sure thing’ and showed me to a barrel when I got there,” she says.

One man’s trash is another Ph.D. student’s treasure. And possibly someday even a tool for keeping your best friend safe while swimming. (Though let’s keep working on fighting climate change, too.)