refactored parsing and then moving to a single function