Fix default value check and null pointer exception