fixed file/dir existence checking