Added moving average algorithm