If you have diabetes, you know that regular exercise should be a key part of your life—it even might allow you to reduce your medication. But if you’re taking insulin—like all people with type 1 diabetes and about 30% to 40% of people with type 2—exercise can be tricky. If you don’t time your snacks and insulin right with the intensity and duration of your exercise routine, you might have an episode of low blood sugar (hypoglycemia), which is no fun—and can be dangerous.

To be safe, you need to take in the right amount of carbohydrates before, during and after your exercise routine…balance that with how vigorously you are working out and for how long…and time your insulin. Not so easy…but now there’s an easier way to calculate what you need to do.

It’s called Excarbs. (The name comes from the need to figure out how many extra carbs you need when you exercise.) It’s an easy-to-use calculator developed by the nonprofit William Sansum Diabetes Center in Santa Barbara, California. The center sponsors scientific research into the artificial pancreas and other technologies, but it also promotes healthy-lifestyle education for people with diabetes.

The online calculator helps you adjust your carb intake and insulin doses according to the kind of exercise you plan to do and when you’re going to do it. To use it, type in your weight, how long and how vigorously you plan to exercise and some details about your medical management of your diabetes such as how much insulin you take, and then hit the button to get a personalized plan for your next workout. If you’re eating a meal within two hours before working out, for example, you’ll get a sample plan with advice to either reduce your insulin dose by a certain amount or increase your carb grams by a certain amount to account for the effect of exercise on blood sugar levels.

If you haven’t been exercising regularly, talk to your doctor before using the Excarbs calculator. The goal of Excarb.com is to support people with insulin-dependent diabetes in exercising safely, and you’ll want your doctor’s input at first to make sure that’s what happens.