improved handling of undefined/null