convert from classical object creation to factory style