reorganized kernelOperation code