added second moment calculation