rewrite main