Fixed a bug when there are no squares.