add NULL pointer protect