fixed ensure-directory