Rewrote the solver itself