Using the xrange iterator instead of just range to prevent memory usage from blowing up