new version of r code for re_int simulation