We’re coming up on the start of the Holiday Season with Halloween right around the corner, and candy will probably be on the table. But, it’s time to watch your candy and sugar intake because you’ve probably heard it all your life: Eating sweets will rot your teeth. But while a diet high in sugar certainly promotes the formation of cavities (as well as other medical problems, such as obesity), sugar itself isn’t the real culprit behind tooth decay.

Dental cavities — also known as caries, the Latin word for “decay” — are formed when bacteria living in the mouth digest carbohydrate debris left on the teeth after you eat. Such debris might include the refined sugars found in cookies, candy, and other treats, but can also come from healthy foods like whole grains, vegetables, and fruits.

What Causes Cavities?

When digesting these carbohydrates, bacteria in your mouth produce an acid that combines with saliva to form that nasty stuff your dentist warned you about: plaque.

It’s plaque — not sugar — that leads to tooth decay. Plaque starts building up after every meal, and if it isn’t brushed away frequently, it can erode the hard, outer enamel of a tooth, resulting in tiny holes in the tooth’s surface. These holes mark the first stage of cavity formation.

And those tiny holes can do a lot of damage if left untreated. Eventually, the acid and bacteria in plaque can eat through the other layers of your teeth, as well — from the softer layer of teeth under the enamel, known as dentin, to the third layer (the pulp), which contains your teeth’s blood vessels and nerves. Cavities affecting the pulp of a tooth, as well as the bone supporting the tooth, can cause severe toothaches, sensitivity, pain when eating and abscesses in the mouth.

Ultimately, sugar is just one of many carbs that can land you in the dentist’s chair, but that doesn’t mean you should trade in your apples for candy corn just yet. In addition to the many health benefits of a plant-heavy diet, the kinds of foods you eat are important to oral health.

Some foods — like hard candy, breath mints, raisins and dry cereal — can get stuck in the grooves and crevices of your teeth, where they could cause decay. Fruit and yogurt, on the other hand, wash away easily with saliva and are, therefore, less likely to cause plaque buildup.

And the way you consume food is just as important as the kinds of food you eat. For example, chugging a can of soda actually does less damage to your teeth than sipping on a soda throughout the day, because the acid created by mouth bacteria sticks around for 30 minutes after you eat or drink. So every time you munch another chip or take a sip of soda, you restart the plaque-production clock and increase your risk of developing cavities.

Carbonated soft drinks also contain phosphoric and citric acids that have been shown to erode tooth enamel. Eating or drinking highly acidic foods — even healthy foods, like citrus fruits — can lead to tooth decay if oral hygiene is not properly maintained.