refactor move parser to regex from state machine