Refactored withTemp & withTempDirectory