Refactored csv parsing