implemented K-means clustering algorithm