core-4165 refactor code