added the checkForDirectory()