Added code to find the interval of the maximum average step