added retransmit code (tentative?)