Fixed bugs in the routing