added state machine