fix csv writing stuff