refactoring csv reading