fixed race condition when having a filename / directory clash