Refactoring : created TaskFactory