Writing the solver