If you want to lose weight, there’s an app for that. Actually, hundreds. Fitbits, step trackers, food logs, calorie counters—people are increasingly using digital tools to fight obesity. But every year nearly 200,000 Americans opt for a more extreme, old-fashioned solution: surgery. Physically altering the size and shape of the stomach has proven to be the most effective and long-lasting treatment for morbid obesity, cutting the risk of premature death by up to 40 percent.

Bariatric surgery comes in a few flavors; there are stomach staples and industrial strength rubber bands. The most successful approach of all—a technique known as Roux-en-Y gastric bypass—is also the most aggressive. But a mounting body of evidence suggests that it may be possible to get all the weight-dropping effects of the procedure without going under the knife at all.

Why? Bacteria, of course!

It turns out gastric bypass not only restructures the topology of the human gut, but profoundly changes which microbes can survive and thrive in it. In a National Institute of Health-backed study published today, researchers at Arizona State University showed that patients who underwent the procedure developed totally different microbiomes, replete with organisms that promoted weight loss. And the effect appears to be permanent. The results confirmed earlier research with a smaller sample size, and also compared gastric bypass with another popular, though less invasive bariatric surgery. Only the bypass impacted microbiome diversity.

Interestingly, the procedure didn’t merely shift patient’s microbial profile from an obese to a healthy one. It actually created an entirely new ecosystem.

Gastric bypass works like this: A surgeon takes the upper portion of the stomach and cordons it off with stitches, creating a small pouch. Then the doctor attaches a Y-shaped section of the small intestine to the pouch, which routes any food you might swallow directly to the second segment of the small intestine, bypassing the portions of your digestive tract that do most of the nutrient- and calorie-absorbing. It’s a pretty dramatic organ-reorganization. One that makes for a less acidic environment with more oxygen, allowing microbes formerly unable to survive in the gut to flourish.

Like, for example Lactobacillus. It’s normally found mostly in the mouth, a much more neutral environment. But as soon as patients get their guts surgically modified, it starts showing up in their stomachs and in their stool samples. And like other members of the Bacillus family, it’s associated with weight loss. In fact, many of the new residents produce molecules that signal appetite-suppressing hormones and other neurological pathways that control eating.

Rosa Krajmalnik-Brown, the environmental engineer who led the study, says they still need to tease out exactly how much of the weight loss effect can be attributed to this unique community of bacteria in humans. But previous work with mice suggests it might be something like all of it. When researchers transplanted beneficial microbes from mice that had undergone gastric bypass surgery into obese mice with normal-sized stomachs, they saw the same kind of dramatic weight loss caused by the surgery itself.

That means if you could find another way to make the gut a happy home for these waste-trimming microbes, you could get the same outcome without the dangers of surgery.

“My vision is to figure out a way to first treat the gut to create the right environment to for this microbiome to establish itself,” says Krajmalnik-Brown. “The end goal is to come up with a probiotic that can be used to enhance weight loss instead of surgery, because surgery is risky.” Only about 1 in 1,000 people who go in for bariatric surgery don't make it out, but the more obese you are the more dangerous it is to go under the knife at all.

Krajmalnik-Brown wouldn't be the first researcher to try to tackle obesity and its related metabolic disorders with probiotics, though she could be the first to succeed. Previous attempts showed promise, successfully altering microbiome composition, before failing to gain meaningful ground in reducing body mass. If cracking the code does in fact all come down to stomach structure, maybe it just took an engineer's eyes to see the way forward.