Replaced python 2.x xrange to python 3.x range