Added type check method for undefined and null.