redo multivariate c to fix reentrancy issues