properly handle missing directories