Milk is nice, but it’s better with Oreos. Turns out cows agree. And lately farmers have been more than happy to indulge them. Corn crops were decimated by a severe drought last summer, pushing prices to a precipitous high. So farmers have had to get creative about what they feed their cattle. Some common solutions: chocolate bars, rainbow sprinkles, gummy worms, and, yes, cookies.

“This has been a brutal year for dairymen,” says Jack Hamm of Lima Ranch in Lodi, California, who regularly adds stale cookies to the feed trough. Luckily, both beef and dairy cattle can thrive on sweets. That’s because their first stomach, or rumen, is loaded with microbes that feast on whatever the animal has eaten. These bugs break large sugar molecules into volatile fatty acids that are absorbed directly into the bloodstream, providing most of the cow’s energy and aiding milk production. Almost no glucose escapes the rumen intact, which is why bovines that eat Cap’n Crunch don’t produce presweetened milk (damn).

“You can take any kind of food and make something out of it,” says Jim Oltjen, an animal science professor at UC Davis. Sweets are fine, as long as they make up a relatively small portion of rations—about a tenth of the 60 pounds of dry feed cattle consume each day. Nutritionists help farmers balance snacks like licorice with byproducts—say, distillers’ grains and grape skins—to find the most nourishing mix for the lowest price. Not what nature intended? Maybe, but Hamm points out that he’s utilizing pounds of stuff that would end up in landfills, reducing his farm’s environmental hoofprint. That’s one way to sugarcoat it.