public function route($performLoading = true): bool
    {
        // Turn the segment array into a URI string
        $uri = implode('/', $this->uri->segments);

        // Fire the event to notify our modules
        $event = Events::fireEvent('routerRouteEvent', $this->routes, $performLoading, $uri);

        // The event has been cancelled
        if ($event->isCancelled()) 
        {
            return false;
        }

        // Assign everything to the object to make it accessible, but let modules check it first
        $routes = $event->routes;
        $performLoading = $event->performLoading;

        // If a cached page should be loaded, do so and stop loading a routed page
        if ($performLoading === true && $event->cacheOverride === false && $this->output->_display_cache() === true)
        {
            return true;
        }

        // Check the custom routes
        foreach ($routes as $route => $value) 
        {
            // Match the path against the routes
            if (preg_match('#^'.$route.'$#', $event->path, $matches))
            {
                $this->logger->log('Route matched: '.$route);
                // Save the matches
                $this->matches = $matches;

                // Are we using callbacks or another method?
                if ( is_array($value))
                {
                    // Maybe there is a real callable which should be called in the future
                    if ( isset($value['callable']) )
                    {
                        $this->callable = $value['callable'];
                    }

                    // If the callable is satisfied, break away
                    if (!$performLoading || $this->loadCallable($matches, $route))
                    {
                        return true;
                    }

                    // Otherwise try other routes
                    continue;
                }
                elseif ( is_callable($value) )
                {
                    // Prepare the callable
                    array_shift($matches);

                    // Retrieve the path that should be loaded
                    $value = call_user_func_array($value, $matches);
                }
                elseif (strpos($value, '$') !== FALSE && strpos($route, '(') !== FALSE)
                {
                    $value = preg_replace('#^'.$route.'$#', $value, $event->path);
                }
                
                if ($performLoading === true)
                {
                    // Now run the defaultRouter for when something is not a callable
                    $this->routeDefault(explode('/', $value), $route);
                    return true;                 
                }

                return false;
            }
        }

        // If we got this far it means we didn't encounter a
        // matching route so we'll set the site default route
        $this->matches = array();
        if ($performLoading === true)
        {
            $this->routeDefault(array_values($this->uri->segments), '.*$');
            return true;
        }

        return false;
    }