rewrite main on change function