fixed tmpfile logic