Fix a null object check