def mean_length(self):
    if self.lenbuffer:
        return np.mean(self.lenbuffer)
    else:
        return 0
def mean_length(self):
    if self.lenbuffer:
        return np.mean(self.lenbuffer)
    else:
        return 0