Some changes to find the best solution