code for solver