added chooseRouter by IP function and added some small changes