Improve the performance for ckmeans algrorithm