added check to see whether a dir is useable