Yes, I realize this is confusing, and that the code isn't very clean here.  I appreciate your suggestion; the latter option is a good solution.  Pushed.