It happens in kitchens across America: You pull out a carton of milk, glance at the sell-by date, and see that it’s passed. Erring on the side of caution, you drain the milk and toss the carton.

But that date is really just a guideline, not some hard-and-fast moment in time at which the milk goes bad. Often, the milk is very much drinkable after the date and throwing it out is a waste.

And now food scientists at Cornell University are trying to take some of the guesswork out of the process by developing a predictive model for the emergence of spore-forming bacteria that causes milk to go bad. They hope the model will help create guidelines for what date should really be on a carton.

The research–which was outlined in the August 2018 issue of the Journal of Dairy Science–has already produced one finding for consumers wondering how long they can keep milk past the sell-by date.

It’s stunningly simple: turn down the fridge temperature and sniff the carton.

“Putting dates on milk cartons is a big issue, because consumers often discard the milk if it is past the sell-by date,” Martin Wiedmann, a food safety professor at Cornell University and a senior author of the research, said in a press release about his study.

“Often there is little science behind those dates, as they are experience-based guesses. The goal of this research was to put good science to use, reduce food waste and reduce food spoilage.”

Milk is increasingly processed via micro-filtering, which removes an impressive 99.5 percent of bacteria in milk through a super-fine filtration process. What’s left behind are spore-forming bacteria–bacillus, Paenibacillus, and Viridibacillus genera—which can survive even the most stringent pasteurization processes, but not cold.

“If we can reduce the spoilage from spore-forming bacteria—by reducing their presence and by controlling their outgrowth—we can see the shelf life for milk improve from two weeks to perhaps a month,” Nicole Martin, research support specialist at Cornell's New York State Milk Quality Improvement Program laboratory and a co-author on the study, said in a press release.

Turning the temperature down just four degrees extended milk shelf life. In a refrigerator set to 42.8 degrees, 66 percent of milk spoiled in 21 days. At the lower temperature of 39.2 degrees, the spoilage rate was 9 percent in the same period. Smelling the milk was a better indicator than the sell-by date for determining if it was sour.

Sell-by or best-by dates became common as refrigerators got more and more popular, allowing families to store food longer, but their genesis is a bit of a mystery.

One urban legend points to Al Capone as the inspiration. Supposedly, a member of Capone’s family fell ill after drinking sour milk, prompting the mob boss to pressure the Chicago City Council to require stamped dates on milk containers.

Whatever its origin, the labeling method was haphazard, with some states using sell-by dates and others using best-by. In 1975, food safety groups pushed Congress to pass legislation that would provide “consistent and coherent messages from the dates they [were] seeing,” according to a report on food waste from the National Research Defense Council in 2011.

But that didn’t really happen, and different states still have their own dating systems. And consumers continue to toss out perfectly good, drinkable milk to the dismay of environmental and food safety groups.

Now Weidmann dreams of a future where scannable barcodes will replace those dates and time-temperature indicators on cartons could tell consumers when that carton of milk is likely to go bad.

“This is the foundational work that could get us there, where consumers could manage their food inventory in the fridge,” Wiedmann said. “That’s the vision.”