                                         r_end = 0;
                                 }
 
-                                //if((lane_id == 0) && (k >= Q_len)) //The entire warp is done
-                                if((k-threadIdx.x) >= Q_len) //If thread 0 doesn't have work, the entire warp is done
+                                if((k-(lane_id*WARP_SIZE)) >= Q_len) //If thread 0 doesn't have work, the entire warp is done
                                 {
                                         break;
                                 }

{
        int j = threadIdx.x;
        int lane_id = getLaneId();
        __shared__ int  *Q_row;
        __shared__ int *Q2_row;


                                k+=blockDim.x;
                                if(k < Q_len)
                                {
					v = Q_row[k];
					//v = Q_row[lane_id*WARP_SIZE + warp_id]; //strided access into the queue to provide better load balancing across warps
                                        r = R[v];
                                        r_end = R[v+1];
                                }
