rewriting flow