check for nil before calling reflect.Value.Set