core-4858 refactor code.