fix to make ensure_dir actually work