Fix a potential bug: Null Pointer Exception.