I'd prefer making a separate global variable for this instead of adding an ad-hoc member to this function (which isn't a technique we usually use).