fixed bug on storing data to csv file