fix potential bug in unwrap method