replaced hard coded classes with factory
replaced hard coded classes with factory