refactoring initgui()