         grad = aval;
         jhere = nbr - x;
         ihere = i + nrows * jhere;
-        __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, x);
+        __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, y);
       }
       grad = aval * Bdata[j];
       jhere = Bir[j] - x;
       if (jhere >= 0 && jhere < ncols) {
         ihere = i + nrows * jhere;
-        __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, x);
+        __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, y);
       }
     }
   } else {

      jhere = Bir[j] - x;
      if (jhere >= 0 && jhere < ncols) {
        ihere = i + nrows * jhere;
        __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, x);
      }
    }
  }

          grad = aval;
          ihere = i + nrows * nbr;
          jhere = nbr;
          __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, y);
        }
        grad = aval * Bdata[j];
        jhere = Bir[j] - x;
        if (jhere >= 0 && jhere < ncols) {
          ihere = i + nrows * jhere;
          __kupdateTile(grad, i, ihere, jhere, MM, Mask, maskrows, lrate, lrlen, limit, y);
        }
      }
    } 
