Fixed bug in UI logic