updated router for more thread safty