rewrite flip