fix bug of moving average