Refactored CSV parsing method