fix k-mean algorithm