convert range() to xrange() for efficiency.