switched from raw pointers to smart pointers