fixed errors in csv saving