Fix a bug to avoid dereferencing a null property