moving average CD calculation bug fixed