fix unwind logic