             ix = thread_index % mx;
             iy = thread_index/mx;
 
-            I = (ix + mbc)*xs + (iy + mbc)*ys;
+            I = (ix + mbc) + (iy + mbc)*ys;
 
             for(mq = 0; mq < meqn; mq++)
             {

        ix = thread_index % mx;
        iy = thread_index/my;

        I = (ix + mbc)*xs + (iy + mbc)*ys;

        for(mq = 0; mq < meqn; mq++)
        {

    double* bmasdq = aux3   + 2*maux;       /* meqn        */
    double* bpasdq = bmasdq + meqn;         /* meqn        */

    __shared__ double dtdx, dtdy;
    __shared__ int xs,ys,zs;

    int mq, mw, m, k;
    int I, I_q, I_aux, I_waves, I_speeds;
    int ix,iy,ifaces_x, ifaces_y, num_ifaces;
    int thread_index;
