refactored parser