implemented sum-squares.