added for loop in sendAndWaitAck