def get_to_be_active_tab(tabs, tabs_indexes, active_tab, previous=False):
    """
    Finds out the next active tab based on user input
    :param tabs: Tabs that shows up in the UI
    :param tabs_indexes: indexed tabs to show them in order
    :param active_tab: Current active tab
    :param previous: Whether or not previous is pressed
    :return: To be Active tab, Whether it is the last tab or not
    """

    # keep track of out of index tab, beneficial to detect the last tab
    no_more_tabs = False

    # find the current active tab index
    active_tab_index = tabs_indexes.get(active_tab)

    # next active tab index based on the button pressed
    if previous:
        active_tab_index -= 1
    else:
        active_tab_index += 1

    # checks out the last tab or not
    try:
        active_tab = tabs[active_tab_index]
    except IndexError:
        no_more_tabs = True

    return active_tab, no_more_tabs