modified the code to properly hook into action accepting the WP_Router object