Fixed bug in CalculateMean