Fixed infinite loop in "State while"