UI script refactoring
Added logic to UI script