Added better detection for replay end event