refactoring KM