-corrected similarity function, added square root calculation to final aggregate sum of difference of squares