algorithm seems to be working
shared pointers etc.