Use last dir method only when valid directory is provided.