Refactoring the way csv data is retrieved