function [Gamma,conv] = newton(Ginit,Tol_Gamma,alpha_hat,z,X,v)

m = 1;
n = size(z,1);
k = size(X,2);
Gamma = Ginit;
gamma = [Gamma(1,:)';Gamma(2,:)'];
Psi = 1;delta = 100; %just to get through the following while for the first time
while norm(Psi\delta)>Tol_Gamma && m<100
    delta = 0;Psi = 0;
    for i=1:n
        if ~ismember(i,alpha_hat)
            delta = delta + kron(...
            ((z(i,:)' - Gamma*X(i,:)')/norm(z(i,:)' - Gamma*X(i,:)') + v), ...
                            X(i,:)');
            Psi   = Psi + kron(...
            (eye(2) - ((z(i,:)' - Gamma*X(i,:)')*(z(i,:)' - Gamma*X(i,:)')')/(norm(z(i,:)' - Gamma*X(i,:)')^2)) ...
                        /norm(z(i,:)' - Gamma*X(i,:)'), ...
                            X(i,:)'*X(i,:));
        end
    end
        m = m + 1;
        gamma = gamma + Psi\delta;
        Gamma = [gamma(1:k,1)';gamma(k+1:end,1)'];
end

if m==100  || any(any(isnan(Gamma)))     
    conv=0;
else
    conv=1;
end