Fixed bug in dictionary replace method