Routing algorithm improved