handle undefined as null