fix bug in wrap method