return type of totype is now a pointer instead of sharedpointer; reducing the number of shared pointers