Changing these to xrange, has a slight (very slight) improvement on speed