Added logic to validate the directory.
Small fix.