Fix undefined and null treatment