Add the main control loop