Added checking for dimensions in k-means algorithm