refactored parsing
Added debugging to parser