state machine working!