modified to be used for r2r