wrap befores and unwrap afters correctly