Implemented function to collect data by case, rather than iteration