adding state machine