Fixed bad index of marg in kernel