rewrite and simplify