refactor to use p ADT instead of parser object