Fix logic error: err != nil -> err == nil