Sub state machine working