Adding code for proper handling of UI