Applying the replacement at the right level