The solver code