modified Solver class and related code. Tested!