implement outputing as csv format