handle undefine as null