Changed v2 to use xrange