Modify to use the smart pointers