The +CEREG URC is being issued by the modem so rather than looping and issuing the AT command the existing URC processing could be used to wait for it.
This is the code that would be replaced.
However a URC callback handler will be added so there won't be a reduction in code size.