fixed definition of wrap()