added movingAverage function