added a new csv output function