Update replace logic.