made ensure_resource for directory creation