add terms to input and output value