Split out square generation into a function.

I'll reuse it.