COMMONS-219 refactoy code