Refactor, repeated code deleted. CustomFactory class instead of OutputFactory and FilterFactory