Fixed a bug with replacement.