fix some problems when checking existing files