refactoring squares