Cleanup UI code

refactored