Controller logic