edited to handle out-of-order r url handlers