refactor csv.php