Updated CUDA implementation