wrap function now working