state machine + typedef