update to write csv files