rewrite program, not finished