Rewriting the kernel of group_by in paralel