fix trying to access property on a null object.