Understanding state machine example