Refactor csv reader