Rearranged the routing code