Add updating key logic