in this way it will always return the best solution that is found