If you’re obese and living with type 2 diabetes, you may have tried in vain to pare off the pounds with a healthier diet and exercise. But gastric bypass surgery may be the best way to achieve your goal, show findings from a new study published in JAMA Surgery and reported by Reuters.

Gastric bypass surgery is one of four types of bariatric procedures designed for morbidly obese patients who have exhausted all other options for losing weight. This procedure essentially reduces a patient’s stomach size from about three pints to roughly the size of a shot glass, and is the most common type of bariatric surgery in the United States.

For the study, researchers reviewed data collected about 569 obese people with diabetes who had undergone different weight-loss surgeries. They also evaluated information about 1,881 obese diabetics who didn’t undergo any type of weight loss procedure.

Findings showed that obese patients who underwent bariatric surgery had an 18-fold higher chance of type 2 diabetes remission (meaning their blood sugar returned to a healthy level without medication) than those who didn’t have surgery. In addition, remission was 43 times more likely for patients who had gastric bypass surgery than those who didn’t go under the knife. Patients who had sleeve gastrectomies were 17 times more likely to achieve remission, and those who had gastric banding operation—the least invasive type of bariatric surgery—were seven times more likely to reach remission.

But researchers warned that the promising results could only be applied to obese patients with diabetes, a metabolic condition that occurs when the body is unable to properly use or make enough of the hormone insulin to convert blood sugar into energy.

They also added that gastric bypass surgeries carry a lot of health risks, such as malnutrition, especially for patients who aren’t obese.

For more information about how weight loss surgery can help treat type 2 diabetes, click here.