Adding the nearest points implementation