resolve the problem of calculation average vs min/max. resolve the ending line.