Added loop for sandwiched segment in the transaction set to match the guide