added ensureExists function