hardened functions against unexpected cases