rearranged routing with "next" function