completed rewrite