swap out inject for each_with_object where apppropriate