fix expandSquares functionality