Added replaceKey function