some refactor in core