Refactoring architecture of the code