working CUDA implementation