dif of squares refactor