Fixed an incorrect null check