Improve the maching to better handle null and undefined.