refactor king