For people living with type 1 diabetes, a constant regimen of checking blood glucose levels, correcting insulin doses, and counting carbohydrates can be more exhausting than the symptoms of the disease itself.

But after more than two decades of careful research, a team of Harvard scientists is on the cusp of releasing an artificial pancreas.

It’s a new technology with a “brain” of its own that could drastically improve the health and lives of the 1.2 million people who suffer from the disease.

“Some people with diabetes are doing a really amazing job managing their diabetes,” said Eyal Dassau, a senior research fellow in biomedical engineering at Harvard who is a key player in the development of the artificial pancreas. “But then you ask the question, ‘How many hours a day are you spending on that?’ And you get the full story. It takes frequent finger sticks and doing small meals and insulin corrections, so many things.

Maybe 30 percent of your day is spent managing diabetes. What if we could cut that time by 50 percent? We’re really talking about quality of life here.”

Read More: Get the Facts on Diabetes »

What’s the Pancreas, Again?

The pancreas is an important little gland that’s part of the digestive system.

One of its functions is to release enzymes that aid in the digestion of food. Its other function is to regulate blood sugar levels by releasing the hormones insulin and glucagon into the blood stream.

In type 1 diabetes, the cells that release these hormones don’t work.

Insulin is what the body uses to move sugar from the blood into the body’s cells to be used as energy.  Without that movement, the body starts to use fat instead of glucose. That can cause serious complications, including severe dehydration and a type of metabolic acidosis known as Diabetic Ketoacidosis (DKA) that can lead to a coma.

Conversely, if the body gets too much insulin from an external source, or a diabetic doesn’t eat enough or has increased physical activity, low blood sugar can quickly develop into a diabetic coma.

In short, careful regulation of blood sugar is imperative to survival for type 1 diabetics. But it’s also a bit of a pain to manage.

Most type 1 diabetics are diagnosed in childhood or early adulthood. Explaining the consequences of poorly controlled blood sugar can be challenging, especially for someone who has not experienced them personally.

Read More: 29 Things Only a Person with Diabetes Would Understand »

A Portable Brain

The team at Harvard, led by longtime artificial pancreas researcher Francis J. Doyle III, has developed technology that utilizes some existing systems for managing diabetes.

Some type 1 diabetics already use two of the artificial pancreas’ components: a continuous subcutaneous insulin infusion (CSII) pump and a continuous subcutaneous glucose monitor (CGM).

These are small devices that free diabetics from constant finger sticks, measuring out doses of insulin, and injecting the medications themselves.

But the new technology also includes a mathematical control algorithm that receives information from the glucose sensor and automatically administers or withholds the appropriate insulin dosage.

The system is “all about prediction” Dassau told Healthline.

Based on a concept known as medically inspired engineering, researchers look at clinical information and studies from doctors who manage diabetes. They then use this information and apply it to what’s known about insulin and glucose, how they function in the body, and the complex system of variables that cause blood glucose levels to either fall too low or rise too high.

“There’s a promised land there. If you’re there, you don’t need to do much,” Dassau said of blood glucose levels.

With the artificial pancreas, regular doses of insulin could be automated based on a person’s normal schedule and needs, as long as that person stays within a safe range of blood glucose values.

But what’s unique about the artificial pancreas is its ability to compensate and adapt to the body’s needs when the levels move outside of that safe zone.

“We have an internal brain that can predict multiple steps in the future, and then make different decisions based on what we call a cost-function,” Dassau said. “So we need to balance between how much insulin you’re going to give and how much you’re going to tolerate being outside the zone … If I’m predicting that we’re going to exit the promised land, before I’m crossing the border, way before that — I can take action to minimize spending time out of the desired zone.”

Read More: Psychoactive Plant May Hold Key to Reversing Diabetes »

The Kids Are All Right

More than 40 clinical trials have been conducted using the artificial pancreas, including a current trial involving 240 patients at nine sites worldwide.

Many companies and research teams similar to Doyle and Dassau’s squads are in the process of developing their own artificial pancreas technology.

Dassau is excited about the current trial, which will have patients using their artificial pancreas at home, with limited monitoring, for 15 weeks.

But, he says, there are constant variables that researchers must account for. Many type 1 diabetics are diagnosed at a young age, but getting permission to do research on children and adolescents can be tricky.

The Harvard team, in collaboration with Yale researchers, is starting to study the pediatric population. They recently worked with the University of Virginia and the Riding On Insulin team of snowboarding and ski instructors to research the efficacy of the artificial pancreas in 16 teenagers with type 1 diabetes.

While it sounds like fun, a week of snowboarding camp with adolescents allowed the research team to analyze the performance of the artificial pancreas in difficult and unpredictable settings. Those included exercise, changes in body temperature, and what passes for a meal in the teen population.

“From each study you learn something new, there’s always new challenges,” Dassau said. “At the diabetes camp with adolescents, I mean, they eat a lot, they exercise a lot.

That’s something that we need to learn how to cope with. So far, the system does really good with different challenges.”

Read More: Diabetics Don’t Have to Shy Away from Wine »

Coming Soon

Dassau notes that because the team, like other teams around the world, is constantly learning and reevaluating their research, it’s hard to say exactly when the artificial pancreas will become readily available to all type 1 diabetics.

He guesses that it will be available within two to five years in some form. The technology, or something like it, might someday be used for type 2 diabetics who use insulin, but that’s much farther off.

While the initial versions will likely still require people to give themselves insulin doses prior to eating, he envisions a form of the technology that will someday be entirely efficient and not require any input from the person wearing it.

“Initially you’ll need to plug in values before meals and give a pre-meal bolus [dose of insulin]” he said. “The dream is that you won’t need to look at it. Eventually it will just work by itself.”