Refactoring and UI update