reorganizing UI code