refactored calculation of squares and changed names