Patients aged 18 years or older with type 1 diabetes were randomly assigned to receive 4 weeks of overnight closed-loop insulin delivery ( using a model-predictive control algorithm to direct insulin delivery ) , then 4 weeks of insulin pump therapy ( in which participants used real-time display of continuous glucose monitoring independent of their pumps as control ) , or vice versa .