refactoring to make csv generation specific to the view