updated KM code