Altering a sequence execution based on response from the driver

The template for the sequence is



bit flag =0;

repeat(10) begin

rsp = my_txn::type_id::create("rsp");

req = my_txn::type_id::create("req");

start_item(req)

if(this.flag) 
     req.randomize with (xyz);//some inline constraint based on flag
else
     req.randomize();

finish_item(req);
//driver-sequence hand shake is finished and let's say driver sent a response by calling item_done(rsp)

//Is this correct?
rsp = get_response(rsp);//get response from the driver and store it to the rsp handle in the txn class

//Is this flag now passed to the next loop iteration? Is this the correct way? OR any other better way?
flag = rsp.flag_info; //signal in the response transaction

end

Now before repeating the next begin end loop where we start/randomize/send another request how can I use some information from the response to alter how the txn should be randomized?

The one I have shared is valid? Is there a better way?