break out handleRouteChange into route function and fixing a bug where base URL was not setting location properly