refactor core a bit