updated stdDeviation calculation