changed checking for existing directory path