Replaced isNaN with a more robust check
Fixed the tmp folder issue
Removed unnecessary variable