                 //uint32_t first_warp_thread_idx = warp * WARP_SIZE;
                 //uint32_t last_warp_thread_idx = (warp + 1) * WARP_SIZE - 1;
 
-            if (thread_idx < 32)
+            if (thread_idx < WARP_SIZE)
             {
 
                 if (thread_idx == 0)

                // to the variable.
                if (__any_sync(0xffffffff, update))
                {
                    uint32_t val_thread = (read_count - 1) % 32;
                    max_score = __shfl_sync(0xffffffff, score, val_thread);
                    maxscore[thread_idx % 32] = max_score;
                    maxi[thread_idx % 32] = __shfl_sync(0xffffffff, i, val_thread);
                    maxj[thread_idx % 32] = __shfl_sync(0xffffffff, j, val_thread);

                }
            }

            __syncthreads();

            if (thread_idx >= 32)
            {

                if (thread_idx == 32)
                {
                    score = max(prev_score[0] + GAP, score);
                    //printf("score for thread %d location %d is %d with prev_score %d\n", thread_idx, j, score, prev_score);
                }

                max_score = maxscore[thread_idx % 32];

                // While there are changes to the horizontal score values, keep updating the matrix.
                // So loop will only run the number of time there are corrections in the matrix.

    //__shared__ int16_t score_i[1024];
    //__shared__ int16_t score_prev_i[1024];

    __shared__ int16_t prev_score[1];

    // Storing max score, i and j for every thread.
    // The values will be replicated across threads to
    // minimize bank confliects when reading the values.
    __shared__ int16_t maxscore[WARP_SIZE];
    __shared__ int16_t maxi[WARP_SIZE];
    __shared__ int16_t maxj[WARP_SIZE];

    uint32_t thread_idx = threadIdx.x;

    long long int start = clock64();
