code refactoring and GUI improvement