function [ q3, eW]=...
    inner(q1, q2 ,inner_parms, parms)

%this function will apply the t41/t23 acceptance probability 
%during the simulation, which may improve the ar

x_lower=inner_parms(1);  x_upper=inner_parms(2);
y_lower=inner_parms(3);  y_upper=inner_parms(4);
innersteps=inner_parms(5);
dx_max=inner_parms(6); dy_max=inner_parms(7); 
dx_12=inner_parms(8); dy_12=inner_parms(9); 
RL=[x_lower;y_lower];
num_trials=inner_parms(10);

RM_12=[ (x_upper-x_lower)*dx_12 0 ; 0 (y_upper-y_lower)*dy_12];  
RM=[ (x_upper-x_lower)*dx_max 0 ; 0 (y_upper-y_lower)*dy_max];  

p1        = e_V(q1(1), q1(2), parms);
p2        = e_V(q2(1), q2(2), parms);  
%eW=p2/p1;
dq_12=q2-q1;
qk=q2; p0=p2; pk=p2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:innersteps %innersteps
    dq=RM *( rand(2,1) - 0.5);
    qkt     = qk + dq ;
    pkt     = e_V(qkt(1), qkt(2), parms) ;
    qkp1=qkt;  %assume the trial is accepted.
    pkp1=pkt;
    t23(k)=pkp1/(pk+pkt);
    rk = qk-dq_12;   prk   = e_V(rk(1), rk(2), parms)     ;
    rkp1=qkp1-dq_12; prkp1 = e_V(rkp1(1), rkp1(2), parms) ;
    rkp1t=rkp1-dq;   
    prkp1t  = e_V(rkp1t(1), rkp1t(2), parms)   ;
    t41(k)=prk/(prkp1+prkp1t);
    if (rand<t23(k)*t41(k)),qk=qkt;,
    else
    t23(k)=1-t23(k); t41(k)=1-t41(k);
    end
end
q3=qk;
eW=1;
%keyboard;

