refactored the parser with an object oriented approach