Added exception handling for bad directory names