fix nearestK bug