Finding the nearest neighbors