Avoid exception with ReplaceDictionary