Added code for bulk exporting to CSV