Nitpicking, but replace() is conditional anyway: it won't do anything if the key doesn't exist.