created method for exporting to csv file