refactering xmeans.py