Write function to simplyify terms in sum of expressions