changed rerouting logic