$opts{dir} is initialized with undef.
so exists always return true.