Whoops!  Because I changed the indexing of the columns and rows in longlist I needed to also change what i and j pointed to.