Fixing a undefined vs null check