Split some functions for code quality improvement