any reason why we need local mappings to these variable, and cannot just use res.`type` everywhere?