improve - use state machine implements cookie parse