Fixed critical bug with replacements