Fixing issue where we could be crashing due to accessing a null pointer