Fixed a bug where old text would not be replaced correctly by the new text