Refactoring to extract the constructor algorithm