a simplify function