refactored parsing