fix ensure index