implemented un/wrap auto-detection