refactor kernel