rewrote gui codes in EMACS