Fixing the outofrange exceptions (correcting it so that first iter is row-based using height, and second iter is column-based using width)