You can make use of the variable smallest whose value is initialized to be a large number, say 1000000 kg, which is (fortunately!) greater than the emissions of any route. You can then compare the emissions of each route to smallest, and if the emissions of the current route are less than smallest, update the value of smallest. Every time you do so, you should also assign the current route to best_route. At the end, the route with the least emissions will be stored in best_route and its emissions will be stored in smallest.