fixing a bad error logic in checking for directory existence