added generic wrap function