First clean version of the cuda implementation