core-4428 refactor code.