Cleaning up csv export code