rewrite outfunction