fixed issue with passing a shared_ptr by ref to lambda