Add protection for kmeans input