code clean up, moving some of the router context out into helper functions in case they change later on