Refactoring done with factories