improve directory existence check