The only thing better than enjoying a delicious dinner is eating it again for lunch the next day. Even the most delicious leftovers, however, can be perilous. We know that food left sitting in the fridge can become a breeding ground for dangerous bacteria, but on the other hand, we don’t want to waste even more food than we already do by tossing Tupperware we could have first emptied into our bellies. So how do we know what’s safe?

Ken Diplock is a public health inspector and a professor at Conestoga College in Ontario, Canada. Among other things, he’s taught plenty of food safety courses and written papers with titles like “Food Safety Education Needs of High-School Students: Leftovers, Lunches, and Microwaves.” In other words, he’s the man to ask about whether that takeout in the back of your fridge is still good. The consequences of using guesswork can be serious, so here’s what home cooks (and the people they feed) need to know about food safety:

Thinking about food safety? Think FAT TOM.

Although specific foods such as rice have the reputation of being major culprits of foodborne illness, it’s better to think of all food as having the ability to make you sick, says Diplock. “You’ve got to always assume that any food coming in may have a pathogen in it,” he says. That way, you’re always observing safe food handling practices.

To evaluate the risk posed by a particular dish, food safety experts recommend using the mnemonic FAT TOM, which describes the six factors that influence how pathogens grow: Food, Acidity, Time, Temperature, Oxygen, Moisture. The goal of kitchen safety is basically to keep the things on this list under control so food will remain safe and last longer, so you should always be thinking about how they play into one another when you’re cooking or storing food. The good news is that a safe kitchen also creates the right conditions for making food last. Rice that’s been properly cooled and promptly stored in a sealed container, for example, has a longer shelf-life than rice that’s left on the stove for a couple of hours after cooking, then put in the fridge in that same pot. That’s because you’ve done your best to keep the dish at a safe temperature, oxygen level, and moisture level (we’ll explain how in a minute). Food that’s dried out, either with heat or with salt curing, will last longer. So will food deprived of oxygen by way of canning or a technique called confit, which smothers meats in fat. Keeping foods at the right temperature during their prep and storage (and reheating them properly) will minimize danger, as will a certain degree of acidity—that’s how pickling works. Eventually, everything will go bad, so older is generally less safe. You can get more specific guidelines on these factors here.

That F for Food is the most important player in the FAT TOM game. Bacteria like to eat the same foods we do—they need nutrients. Start by looking at high-protein, high-moisture foods like meat, Diplock says. Bacteria love a juicy steak just as much as you do. Don’t eat animal products? Don’t worry; many microbes are happy to go vegan right along with you. Veg foods that are high in protein pose the same risk, Diplock says. And any food that is wet should be an object of suspicion, because water is a basic condition for bacterial life.

How to keep food safe for longer:

So, how do we minimize the dangers outlined by our friend FAT TOM? There are some basic safety steps you should always follow, whether you’re meal prepping for the week or just trying to save leftovers for tomorrow. This advice holds true whether we’re talking about a pot of paella, a pan of chicken thighs, or a pack of tofu scrambled into a stir-fry.

To start with, “you don’t want to take a hot product off the stove and immediately put it in the fridge,” says Diplock. Leave it out on the counter for half an hour to an hour, until it cools to approximately room temperature, he says. If you just put a hot dish full of food right into the fridge, it’ll warm up everything else inside the icebox before it actually starts to cool down.

Then transfer it into a shallow container, to increase the surface area, and cover the dish—but leave a little bit of room for air and moisture to get out as the food continues to cool (you can accomplish this by leaving the lid a little bit unsealed, or pulling back the corner of whatever wrap or foil you’re using). Only then should you plunk it in the fridge to cool fully. Once it’s actually cold, you can seal the container entirely without worrying about trapping a ton of condensation for bacteria to thrive in.

The temperature continues to be key: Keep a thermometer in your fridge so you can make sure it stays at a steady 39.2 degrees Fahrenheit, says Diplock, and aim to reheat leftovers to the same temperature they were first cooked at. Anything between 40 degrees Fahrenheit and 140 degrees Fahrenheit is considered to be the “danger zone” where bacteria populations can explode. Anything too cold, and you risk damaging food quality by accidentally freezing it.

Okay, but how do I know when food is dangerous to eat?

Think that a simple sniff can tell you everything you need to know? “No. Absolutely not,” says Diplock. A sniff can only tell you if food is starting to spoil, also known as literally rotting. Putrid food is more likely to carry dangerous bacteria (and more likely to taste super gross) than products that haven’t yet started decomposing. But smell can’t tell you anything—not one single thing—about foodborne illness. Dinner doesn’t have to go bad to be bad for you.

According to the World Health Organization, more than 200 different illnesses are transmitted by food. Common culprits for the home cook are bacteria like E.coli, salmonella, and campylobacter, as well as viruses like norovirus. Even reheating food might not save you: some pathogens produce toxins that stay dangerous even at temperatures that kill the bacteria themselves.

But the best offense is a good defense. Instead of fretting over whether you might get extremely unlucky despite taking all the precautions above, fret over how much higher your risk of illness will be if you don’t take those precautions. However diligent you are about food prep and storage, Diplock says, one simple step can go a long way: “Wash your hands.” If you keep your cooking tools—including your hands—and surfaces clean, you’ll at least minimize a lot of the risk of contamination. But if saving delicious leftovers for as long as possible is your goal, it’s time to invest in a few thermometers.