simplify with a function