fix replacement message handling