Generalize wrapping code