Discusting example of state machine