Add factory pattern