refactored + exporting the results as csv