What about creating the temp dir in the outer function?