modified and added algorithm for Solver