refactor core part