some changes to the iteration in neighbor_iterator