Refactor the expand code from Simplify to CTerm