Rewrite Main file