I don't like how this endif wraps the else clause here.  Perhaps have a new if outside of the endif that checks if NULL == regs?