improvements in moving average calculations