Determining the best solution