factor out a common stanza