Substituted `xrange` with `range` to enhance python 3 compatibility.