Rewrite implementation