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


%this function takes q2 as an argument, rather 
%than generating it in the routine

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) ;
%     if (rand<pkt/(pk+pkt)), 
%       pkp1=pkt; qkp1=qkt;
%     else
%       pkp1=pk; qkp1=qk;  
%     end
%     t23(k)=pkp1/(pk+pkt);
%     % - computing reverse trajectory:  
%     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);
%     % - done computing reverse trajectory
%     qk=qkp1; pk=pkp1;
% end

%jn trying the acceptance in the inner loop
for k=1:innersteps %innersteps
    dq=RM *( rand(2,1) - 0.5);
    qkt     = qk + dq ;
    pkt     = e_V(qkt(1), qkt(2), parms) ;
    if (rand<pkt/(pk+pkt)), 
      pkp1=pkt; qkp1=qkt;
    else
      pkp1=pk; qkp1=qk;  
    end
    t23(k)=pkp1/(pk+pkt);
    % - computing reverse trajectory:  
    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);
    % - done computing reverse trajectory
    qk=qkp1; pk=pkp1;
end


q3=qk;

% p3=p0;
% 
% q4=q3-dq_12;
% p4= e_V(q4(1), q4(2), parms);  
%eW=(p4+p1)/(p2+p3);
eW=prod(t41./t23);
%keyboard;

