def correct_size(sampling, targetsize):
    """this removes trailing entries in sampling until its size is equal to targetsize"""
    while len(sampling) > targetsize:
        sampling.pop(-1)
    return sampling
