changed range to xrange where a generator is more appropriate than a list