This article originally appeared in Shape.

Like many people, you probably face this constant conundrum when you walk into the gym: Should you do cardio before or after lifting weights?

The short answer is: It largely depends on your goals.

"For example, if you're training for a marathon or any long-distance run, I would prioritize your run before strength training so you can focus on that without the distraction of your legs being fatigued," says Nike master trainer Betina Gozo. On the other hand, if your goal is to build stronger glutes, you might want to hit the squat rack before the treadmill. "There's so much more muscle recruitment needed in strength training, so you would want to save all the energy you can for it," says Gozo.

That said, even if you don't have a super-specific goal and want to train for better overall fitness, it's important to combine cardio and strength wisely so you don't overwork the same muscle groups. According to the American College of Sports Medicine, doing similar endurance and strength training back-to-back doesn't allow for adequate recovery and could lead to fatigue and poor performance (thus increasing your injury risk), so you should carefully consider the type of exercises you're doing.