     }
   }
 
-  if (THCudaTensor_nDimension(state, tensor) > MAX_CUTORCH_DIMS) {
-    return THArgCheck(false, 1, CUTORCH_DIM_WARNING);
-  }
+  THArgCheck(THCudaTensor_nDimension(state, tensor) <= MAX_CUTORCH_DIMS, 
+             1, CUTORCH_DIM_WARNING);
 
   const long totalElements = THCudaTensor_nElement(state, index);
   const dim3 block = getApplyBlock();
   dim3 grid;
-  if (!getApplyGrid(state, totalElements, grid)) {
-    return THArgCheck(false, 1, CUTORCH_DIM_WARNING);
-  }
+  THArgCheck(getApplyGrid(state, totalElements, grid), 1, CUTORCH_DIM_WARNING);
 
   THCudaTensor* oldTensor = NULL;
   if (THC_overlappingIndices(state, tensor)) {

    }
  }

  if (THCudaTensor_nDimension(state, tensor) > MAX_CUTORCH_DIMS) {
    return THArgCheck(false, 1, CUTORCH_DIM_WARNING);
  }

  const long totalElements = THCudaTensor_nElement(state, index);
  const dim3 block = getApplyBlock();
  dim3 grid;
  if (!getApplyGrid(state, totalElements, grid)) {
    return THArgCheck(false, 1, CUTORCH_DIM_WARNING);
  }

  THCudaTensor* oldTensor = NULL;
  if (THC_overlappingIndices(state, tensor)) {

    }
  }

  THArgCheck(THCudaTensor_nDimension(state, tensor) <= MAX_CUTORCH_DIMS,
             1, CUTORCH_DIM_WARNING);

  const long totalElements = THCudaTensor_nElement(state, index);
  const dim3 block = getApplyBlock();
  dim3 grid;
  THArgCheck(getApplyGrid(state, totalElements, grid), 1, CUTORCH_DIM_WARNING);

  THCudaTensor* oldTensor = NULL;
  if (THC_overlappingIndices(state, tensor)) {
