updated router logic