implemented marginal function for variables