rewrite flow control