Fixed ControlLoop and error function