Added logic to the UI