refactored the UI generation