rewrite routing functions to be more portable