fix factory implemntation