updated control loop