Function rewrite