Added factory pattern.