Although we know that we should all be working out at least 30 minutes a day, outdoor activity can be less than appealing when it’s hot and sticky. However, while working out in the dog days of summer may not seem like the most fun you could have, there are some surprising benefits: in a recent study conducted at the University of Oregon, researchers found that exercising in the heat might actually improve athletes’ performance.

There are, however, a few things that we need to keep in mind in order to work out safely in the heat, including monitoring water intake, clothing choice, and cardio condition. “One of the most challenging aspects of training, especially in the hotter months of the year, is managing your fluid intake,” says Marxel Leobez, trainer and creator of Power Xculpt yoga. “Your body simply can’t perform to its potential if it’s dehydrated,” he tells us. So how do you train in the heat safely? We’ve got a full run-down to keep you going strong all summer long.

Pre-Workout

Start hydrating for your next workout at a time that is equal to the duration of your planned training session. That means if you are going to be exercising for 60 minutes, then your prep needs to begin one hour before putting on your sneakers.

Mid-Workout

On a hot day, your target is approximately four ounces of fluid per mile, says Leobez. Pick a beverage that can replenish your electrolytes in order to avoid cramping, such as coconut water or plain old H20.

Post-Workout

Within 15 minutes of finishing your workout, grab a snack: a mix of carbs and protein like yogurt mixed with nuts is best. Monitoring your urine is one of the easiest ways to tell if you’ve had enough liquids; if it’s the color of lemon juice or lighter then you are doing okay, but if it’s darker you might want to drink up. (Ok, this might sound weird, but … you may want to take a look at Gut Health: 6 Reasons to Check Before You Flush).

What to Drink

Make sure that you are taking in both water and something more nourishing like a sports drink, says Leobez. Maple Water or watermelon drinks are also great ways of replenishing your fluids as well as electrolytes.

Fun in the Sun

Although it’s great to feel light and carefree when hitting the outdoors, you need to think ahead a little and protect yourself. “Always wear a broad-spectrum sunscreen and sunglasses before heading out,” says trainer Alison Heilig of AcaciaTV. “Pick lightweight, UV-treated, sweat-wicking fabrics to stay cool,” she says. (Not sure which ones to buy? We’ve got you covered: check out The Best Sunscreens of 2015).

Keep it Indoors

As dedicated as you may be, there are times when it is safer to hit the air-conditioned gym than your local park. “Our bodies can adapt to heat,” says Heilig. “Temperature is only one part of it: anything above 40% humidity could impact your body’s ability to cool itself.” This can lead to rapid heartbeat, cramping, heat exhaustion, or heat stroke — all potentially dangerous conditions. So listen to your body and accept your limitations.

Consider the Best Time to Hit the Track

The best time to get out there and shake your groove thing is when the temperature is lower, in the early morning and late evening, so any time between 11 and 3 pm might not be your best bet. Don’t be afraid to scale back your intensity when it is sticky and hot out there. A shaded trail close to water is a great option on a hot day, and so is swimming.

What to Eat

Heilig suggests foods with high water and potassium content, such as melons and bananas. She nibbles these pre- and post-workout; not only do they keep energy up, but they stave off spasms and cramps as well.