function f = CF_Find(guess);

global beta delta alpha1 alpha2 alpha3 Hs He bank rp eta mu sigmacs Ls nu
if min(guess)<0
    f = 100;
else

omegab = guess(1);
sigma = guess(2);

M = -0.5*sigma^2;
PHIs = normcdf((log(omegab) - M)/sigma);
phis = normpdf((log(omegab) - M)/sigma)/(omegab*sigma);
gs = normcdf((log(omegab)-M-sigma^2)/sigma) - PHIs*mu + (1-PHIs)*omegab;
fs = 1-mu*PHIs-gs;
qs = (1-PHIs*mu-phis*mu*fs/(1-PHIs))^(-1);
gamma = (1-qs*gs)/(qs*fs); %using normalization 
rs = qs*(1-beta*(1-delta))/beta;
Ks = (rs/(alpha1*Hs^(alpha2)*He^(alpha3)))^(1/(alpha1-1));
Ys = Ks^(alpha1)*Hs^(alpha2)*He^(alpha3);
ws = alpha2*Ks^(alpha1)*Hs^(alpha2-1)*He^(alpha3);
xs = (alpha3)*Ks^(alpha1)*Hs^(alpha2)*He^(alpha3-1);
Is = delta*Ks/((1-PHIs*mu));
is = Is/eta;
ns = is*(1-qs*gs);
kes = (ns-xs)/(rs+qs*(1-delta));
ces = qs*fs*is - qs*kes;
cs = (1/(1-eta))*(Ys - eta*ces - eta*is);
chi = cs^(sigmacs) * ws /(Ls^(1/nu));
rks = omegab*(is/(is-ns))-1;

% targets
bankr = PHIs - bank;
spread = qs*(1+rks)-1 - rp;

f = 1000*[bankr;spread];
end