Added functionality to export to csv