we could define this at file-level, instead of inside this one function. I generally try to avoid nesting functions unless they need to close over some value, or if they ought to be hidden from the outside scope.