refactored UI code