added unique counting to inform the KNN computation