Fix indexing issue on order replacement