improve wrap functionality