first iteration using squares