removed usage of xrange for python 3 compatibility