Fixed error in command sequence loop exit condition