added state machine diagram