working correct marginals