Check for null values to prevent crash on line 535