a function rewrite