Fix replacement edge case