Fix for the wait state immediately switching back to the previous state