Bug fix for Python 3 compatibility: xrange() is gone