changed call to range() from xrange().  indexing needs the array, not the generator