updated definition of wrap()