Refactored the data handling stage, using filter on arrays instead of iterating all the entries and checking them individually.