Update replace function logic.
1.0.5