modify how to write into csv files