Fix a possible nil bug