_.groupBy could probably simplify the badging logic