Refactor replay mechanism