If you turned over a new leaf this year and are vowing to stick with your exercise plan, you likely already have most of the gear you need, from a kickin’ pair of athletic shoes to a shiny new eco-water bottle, but there is one crucial element you may have missed. What are you eating? Knowing what to nibble on before and after you exercise can be the difference between meeting your fitness goals and falling headlong into a tub of gelato by nightfall.

The goal is to fuel your fitness, to stay energized without eating so much you upset your stomach. If you are always pushing yourself to workout when you feel pooped, it’ll be tough to stick to the plan overtime.

“If you haven’t eaten in a long time, your body is in a fasted state,” Nancy Cohen, a professor in the department of nutrition at the University of Massachusetts in Amherst told CNN. “Normally, your body will use glucose for fuel and begin to break down muscle glycogen to deliver the glucose your body needs for exercise. In a fasted state, the muscle glycogen will be depleted sooner. Your body will then turn to breaking down fats for the energy it needs.”

But you don’t want to eat a whole cheeseburger either. As Consumer Reports advises, a snack packed with fiber-rich carbs and protein right about 30 to 60 minutes ahead of a workout is just about perfect. Think small snack, maybe around 200 calories.

And tailor the food to the activity. If you are lifting weights to build your strength, go with protein, like Greek yogurt, almonds or string cheese. If you are breaking a sweat with cardio, complex carbs such as raisins or string cheese might be ideal.

This may sound surprising but what you eat right after is also key to getting in shape, notes Consumer Reports. If you are trying to lose weight, you don’t want to find yourself famished by dinner time, which may lead to poor choices (pizza delivery!).

Instead keep your appetite in check. Nosh on a healthy post-exercise appetizer, such as apple slices with peanut butter, that keeps you going and helps replenish the body so you’re not totally wiped out. And don’t forget to rehydrate.