Refactored csv output