rewrite program