updated to use shared_ptr