Functions rewrite