added missing global reference for  in updateKey function line 7