refactory the UI