missing .exists() method call in dir existence check added