Added function for writing to excel