     if (i >= n_scratch) return;
 
     unsigned int pidx = d_scratch_idx[i];
-    unsigned int offset = d_offset[i] + pidx;
+    unsigned int offset = d_offset[i]*pidx_group_table_pitch + pidx;
     d_pidx_group_table[offset] = d_scratch_g[i];
     }
 

    const group_t *d_scratch_g,
    const unsigned int *d_scratch_idx,
    const unsigned int *d_offset,
    group_t *d_pidx_group_table
    )
    {
    unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;

#include "ParticleData.cuh"
#include "BondedGroupData.cuh"

#include "moderngpu/kernels/scan.cuh"
#include "moderngpu/kernels/mergesort.cuh"
#include "moderngpu/kernels/intervalmove.cuh"

/*! \file BondedGroupData.cu
    \brief Implements the helper functions (GPU version) for updating the GPU bonded group tables
