A healthy diet can do more for you than just lower your weight. It can also affect your heart, lower your risk of disease including diabetes and cancer, and studies have shown that what you eat may affect your memory later in life. But how it affects your memory depends on the kinds of food you eat.

How food can help – or hurt - the mind

Just as unhealthy foods can build up plaque in your arteries, there are some foods that can create toxins that harm the mind. It’s especially true for foods high in saturated and trans fats. The toxins these foods create can lead to inflammation and the build-up of plaque in your brain, which may lead to impaired brain functions and loss of memory.

Research by Harvard Medical School and others indicates a specific gene may be the link between plaque and poor memory. The gene, called “APOE,” is associated with the cholesterol in your blood. People with a variation of the gene have more plaque build-ups in their brain, which is a telltale sign of Alzheimer’s disease. Plaque build-up in your arteries can restrict the amount of blood making its way to your brain, which can lead to impaired brain functions or even stroke.

Foods that can hurt your memory

So what are some specific foods that can hurt your memory? Unfortunately, you probably eat several of these a few times a week. White bread and flour, as well as pasta, sugar, processed meats, and processed cheeses have all been linked to Alzheimer’s disease. So have excess levels of margarine and even beer.

Why do these foods affect your memory?

The white foods listed above, as well as foods like white rice, crackers, and some cakes can cause a rise in insulin levels, which can lead to inflammation. The rise in insulin can also release toxins in your brain.

Processed meats and cheeses can be harmful for similar reasons. Processed meats, like bacon, cold cut meats, and sausages may contain a chemical compound called “nitrosamines.” This compound can cause the liver to produce fats that are toxic to the brain. Processed cheeses, including American cheese, spray cheese, and even mozzarella sticks build up proteins in the body that have been linked to memory loss.

But what about margarine and beer? They both contain chemicals linked to Alzheimer’s. Margarine contains diacetyl, a chemical linked to plaque build-up in the brain. Some microwave popcorns also contain diacetyl. Beer also contains diacetyl, as well as chemicals called nitrates. Nitrates are similar to the nitrosamines found in processed meats. While moderate consumption of beer can be good for you, too much can tip the scale in the other direction.

Is it too late to change?

Chances are you eat some of those foods on a regular basis, which might have you worried. There is good news though. Our brains are very resilient, and they have a certain characteristic called “neuroplasticity,” or plasticity for short. This means your brain has the ability to heal itself and adapt to new circumstances.

The best way to help your brains natural plasticity is to eat foods that are good for it. Which brings us to our next section:

Foods that are good for the brain

Since saturated and trans fats have been shown to cause impaired brain function, it would be reasonable to assume their opposites would be good for the brain. Those types of foods contain unsaturated fats. There are two types of unsaturated fats, polyunsaturated and monounsaturated, and are mostly found in foods belonging to the Mediterranean Diet.

The Mediterranean Diet

You might have heard of the Mediterranean Diet before, it involves lots of vegetables and fish. Research shows that foods in the Mediterranean Diet helps keep your brain sharp, and may improve cognitive function, memory, and alertness. To break it down further, try to eat as many of these foods as possible:

Leafy green vegetables. Including kale, cabbage, and even broccoli. They can improve the health of blood vessels going to the brain, and reduce the risk of a stroke.

Fish rich in omega-3 fatty acids. These have been linked to lower levels of proteins that can be harmful to the brain. Your brain also has high levels of a specific fatty acid called docosahexaenoic (DHA), and eating more will help it run more efficiently.

Berries. Dark berries especially, like blueberries, blackberries and cherries, are a rich source of antioxidants. Antioxidants lower inflammation in the brain, which may lower your risk for memory loss.

Walnuts. Walnuts are a great superfood. They are high in omega-3, can raise your melatonin levels which will give you a good night’s sleep, and can reduce cholesterol. They are also full of polyunsaturated fats.

Coffee. Studies have shown that drinking about one or two cups of coffee daily can improve your brain health. Unfortunately for you coffee guzzlers out there, the benefits stopped at two drinks. No association was found for three or more.

Wine. Moderate alcohol consumption, espescially wine, has been shown to improve brain health as well. Most studies recommend 5 ounces, or one glass.

If you’ve heard of the health benefits of these foods before, that’s because they’re not just good for the brain. Many of the foods on this list are also good for your heart and other parts of the body. They won’t work overnight, but if you eat them consistently over time, your brain will thank you.