refactoring UI functions