Fixed missing check for null