fix ensure logic