Added a (CPU) kernel function to make the cuda implementation easier later on