ECMS-6493 refactor code