added directory check and creation if no tmp folder exists