refactor code in parsers