fix bug so that the non linear solver converge and clean the code