optimized calculation, Max and average method add