Is there a clear reason to prefer inner functions here rather than making these module-level helper functions?  In the absence of a clear reason for inner functions (like access to a local variable in the enclosing function scope), I prefer moving them outside for clarity.