implementation of get_neighbors