UI code refactoring