function rewrites