Refactor to remove iterator dependence. some loss of functionality