refactored some UI functions