correct a bug in sumOfSquares