updated routing algorithm