modified ioreplayer and refactored