refactoring for CSV support