Extract func for finding neighbors