replace inject with each_with_object