core-4333 refactor code