function [ q3, eW]=...
    inner(q1,inner_parms, parms_1,parms_2,L1,L2)


%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        = (1-L1)*log(e_V(q1(1), q1(2), parms_1))+...
               L1*log(e_V(q1(1), q1(2), parms_2));
p1=exp(p1);
p2        = (1-L2)*log(e_V(q1(1), q1(2), parms_1))+...
               L2*log(e_V(q1(1), q1(2), parms_2));
p2=exp(p2);
eW=p2/p1;
%keyboard;
q0=q1; p0=p2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j=1:innersteps %innersteps
    dq=RM *( rand(2,1) -0.5);
    qt     = q0 + dq ;
%    pt    = (1-L2)*e_V(qt(1), qt(2), parms_1)+...
%               L2*e_V(qt(1), qt(2), parms_2);
    pt    = (1-L2)*log(e_V(qt(1), qt(2), parms_1))+...
             L2*log(e_V(qt(1), qt(2), parms_2));
           pt=exp(pt);
    if (rand<pt/p0), 
      p0=pt; q0=qt;
    end
end
q3=q0;
