switch undefined to null