You shouldn't need to change much in the way of functionality.
You are refactoring, so you want the same functionality before and after your changes, you just want better / more elegant code.
In both cases, squares that are part of "grouped figures" should be counted.