changed replace() to addOrReplace()