fix the bugs in y-wrapping