Fix -nan error in kMeans code