avoid throwing exception when passed null or undefined