Refactored Parser to make it cleaner