I realize that this is an inner function, but a comment here would be helpful for following what's going on.