refactor of the abstract factory pattern