fix nil pointer dereference error
fix logging