Updated the implementation of wrap.