Added logic for working with main UI