Add nil value check

Signed-off-by: leo-ma <begeekmyfriend@gmail.com>