Out-of-date groceries can do more than ruin your dinner. If food is spoiled, it can cause serious illnesses. Luckily, there’s a new way to determine whether packaged foods are still safe to eat—before you buy them.

Researchers recently created a thin, flexible film that fluoresces, or glows, in the presence of E. coli bacteria. Supermarkets can use it to package foods. Then shoppers can scan the packaging with an app on their phone. If E. coli bacteria are present, the phone will provide an alert.

The material could be helpful beyond supermarkets too. It could be a “very useful technology in developing countries for monitoring food and water,” says Tohid Didar, a mechanical engineer at McMaster University in Canada who worked on the bacteria detector.