rewrite phase 1