   /* call cudakernel */
   dim3 blocks(input->size[0]); // each cuda-block is an example
   dim3 threads(LAZYKBEST_THREADS);
-  cunnx_LazyKBest_updateGradOutput_kernel<<<blocks,threads>>>(
+  cunnx_LazyKBest_updateGradInput_kernel<<<blocks,threads>>>(
     THCudaTensor_data(gradInput), THCudaTensor_data(indice), 
     THCudaTensor_data(gradOutput), input->size[0], k
   );

  const int k = blockIdx.x;
  
  float *output_k = output + k*outputSize;
  float *indice_k = input + k*outputSize;
  const float *input_k = input + k*inputSize;
  
  float maxVal = -FLT_MAX;

  float *gradInput, const float *indice, const float *gradOutput, 
  int inputSize, int outputSize)
{
  int tx = threadIdx.x;
  int step = blockDim.x;
  int k = blockIdx.x;
  
  float *gradInput_k = gradInput + k*inputSize;
  const float *gradOutput_k = gradOutput + k*outputSize;
  const float *indice_k = indice + k*outputSize;
  
  for (int i=tx; i<outputSize; i+=step)
    gradInput_k[(int)(indice_k[i])] = gradOutput_k[i];
}


