Change unique_ptr to shared_ptr and for auto