Implemented review comments to use mktmpdir to create temp dir