fix ensure bugs