Fix factory pattern