change to factory pattern