add safecheck for directory