public function dispatch()
 {
     if ($this->router == null) {
         throw new \Exception('No valid router found', 500);
     }
     $_uri = $this->router->getUri();
     $routes = App::getInstance()->getConfig()->routes;
     $configParams = null;
     if (is_array($routes) && count($routes) > 0) {
         foreach ($routes as $key => $value) {
             if (stripos($_uri, $key) === 0 && ($_uri == $key || stripos($_uri, $key . '/') === 0) && $value['namespace']) {
                 $this->namespace = $value['namespace'];
                 $_uri = substr($_uri, strlen($key) + 1);
                 $configParams = $value;
                 break;
             }
         }
     } else {
         throw new \Exception('Default route missing', 500);
     }
     if ($this->namespace == null && $routes['*']['namespace']) {
         $this->namespace = $routes['*']['namespace'];
         $configParams = $routes['*'];
     } else {
         if ($this->namespace == null && !$routes['*']['namespace']) {
             throw new \Exception('Default route missing', 500);
         }
     }
     $this->input = InputData::getInstance();
     $_params = explode('/', $_uri);
     if ($_params[0]) {
         $this->controller = strtolower($_params[0]);
         if ($_params[1]) {
             $this->method = strtolower($_params[1]);
             unset($_params[0], $_params[1]);
             $this->input->setGet(array_values($_params));
         } else {
             $this->method = $this->getDefaultMethod();
         }
     } else {
         $this->controller = $this->getDefaultController();
         $this->method = $this->getDefaultMethod();
     }
     if (is_array($configParams) && $configParams['controllers']) {
         if ($configParams['controllers'][$this->controller]['methods'][$this->method]) {
             $this->method = strtolower($configParams['controllers'][$this->controller]['methods'][$this->method]);
         }
         if (isset($configParams['controllers'][$this->controller]['to'])) {
             $this->controller = strtolower($configParams['controllers'][$this->controller]['to']);
         }
     }
     $this->input->setPost($this->router->getPost());
     //TODO Fix
     $controller = $this->namespace . '\\' . ucfirst($this->controller);
     $newController = new $controller();
     $this->loadMethod($newController);
 }