Total rewrite