refactoring and add UIController class