fixed ensure_index argument bug