Replaced writing to csv files with storing to arraylist