converted to factory from constructor