avoid dereferencing NULL pointer