fixing routing alg