added recursive sum of squares