add interface for csv format and heavy refactor...