def around_pos(normalized, ORI, TER, av_diff):
    """
    Check which indices have a cum value differing less than the average difference

    :param normalized:  Normalized list of skew values
    :param ORI:         Predicted position of ORI
    :param TER:         Predicted position of TER
    :param av_diff:     Average difference between perfect and real data
    :return:            Lists of indices around predicted positions with value
                        differing less than the average difference,and the break points if found
    """
    aroundter = list()
    aroundori = list()
    ori_break = -1
    ter_break = -1
    len_normalized = len(normalized)
    indices = list(range(0, len_normalized))
    """Saves all indices with values differing less than the average difference, 
    and saves the index as a break point when the indices jump more than one step"""
    for val in indices:
        if abs(normalized[val] - normalized[ORI - 1]) < abs(av_diff):
            if len(aroundori) != 0:
                if val > aroundori[len(aroundori) - 1] + 1:
                    ori_break = val
            aroundori.append(val)
        if abs(normalized[val] - normalized[TER - 1]) < abs(av_diff):
            if len(aroundter) != 0:
                if val > aroundter[len(aroundter) - 1] + 1:
                    ter_break = val
            aroundter.append(val)
    """Deletes all indices from list which are less than the break point if 
    the predicted position is above the break point, and deletes all indices
    from list which are greater than the break point, if the predicted position is 
    less than the break point - IF the first index is not the beginning of the sequence 
    and the last is not the end of the sequence."""
    if ori_break != -1 and ORI >= ori_break and aroundori[0
        ] != 0 and aroundori[1] != len_normalized - 1:
        del aroundori[0:aroundori.index(ori_break)]
    elif ori_break != -1 and ORI < ori_break and aroundori[0
        ] != 0 and aroundori[1] != len_normalized - 1:
        del aroundori[aroundori.index(ori_break):]
    if ter_break != -1 and TER >= ter_break and aroundter[0
        ] != 0 and aroundter[1] != len_normalized - 1:
        del aroundter[0:aroundter.index(ter_break)]
    elif ter_break != -1 and TER < ter_break and aroundter[0
        ] != 0 and aroundter[1] != len_normalized - 1:
        del aroundter[aroundter.index(ter_break):]
    return list(aroundori), list(aroundter), ori_break, ter_break
