further refactor of parser