It looks like this small inner function has only one caller now, so there doesn't seem to be much value from writing this code as a function. What do you think about just moving the contents of this function directly into the `if-statement` above?