added moving average calculation