fix bug in CSV generation