As the weather turns warmer, you may feel the urge to reach for something cool to eat. But you’d be doing yourself a favor by swapping that frozen yogurt for some Buffalo wings.

Humans have long combatted the heat by eating spicy food. And while it may seem counterproductive to chow down on some salsa while baking in the sun, there’s sound evidence to suggest it will help you cool down.

The secret? Sweat. Chilis like cayenne, jalapeño, and habanero peppers get their heat from the chemical capsaicin, which acts as an irritant for certain animals—including humans. When you ingest capsaicin, it triggers a neural response from your body. As Yale professor Barry Green explained in Scientific American,

…spicy foods excite the receptors in the skin that normally respond to heat…The central nervous system reacts to whatever the sensory system tells it is going on. Therefore, the pattern of activity from pain and warm nerve fibers triggers both the sensations and the physical reactions of heat, including vasodilation, sweating, and flushing.

The “burn” you feel in your mouth from eating spicy food can be followed by a similar warming sensation across the rest of your body, causing you to sweat as you eat. Sweating is one of the primary methods the human body has to regulate its temperature—specifically, it’s the evaporation of sweat that removes heat from your body. So as long as you stay hydrated while eating spicy food, the perspiration that comes from enjoying a good three-alarm chili will force your body to cool itself quickly and more efficiently.

One person’s spicy is another person’s bland

It’s good to know that spicy food can help cool you down, but it isn’t particularly useful unless you enjoy—or in some cases, simply tolerate—the mouthfeel of spice. But fear not! Even if your diet has always skewed toward the tame, it’s not too late to teach your tongue to enjoy the burn of spice.

Accord to food science writer Jeff Porter, author of “Cooking for Geeks,” it just takes a little time:

The reaction to hot peppers is governed by a neurotransmitter called substance P (P is for pain; go figure). In one of nature’s more subtle moves, substance P can be depleted slowly and takes times—many days, possibly weeks—to replenish, meaning that if you eat hot foods often, you literally build up a tolerance for hotter and hotter foods as your ability to detect their presence goes down.

There’s no trick to tolerating spicy food other than practice, practice, practice. Start by adding small doses of spice to your normal meals on a regular basis, and eventually work your way up to hotter dishes. Whereas once you may have balked at the sight of lamb vindaloo, within weeks you could be enjoying all the flavors (and cooling effects) spicy food has to offer.