Doing the defer here means that res will not be nil.