complex rewrite