refactoring for UI