Refactored parser code