i made a new method called checkForOptimalSolution