change auto_ptr to shared_ptr