made it CUDA friendly