minor changes to moving average function