rewrite, avoiding measurements