re-implement parse_url,state transition