Replace each_with_object for inject.