diff --git a/graphapi.module b/graphapi.module
index 1ddc7de..24930a7 100644
--- a/graphapi.module
+++ b/graphapi.module
@@ -365,26 +365,21 @@ function graphapi_theme() {
  */
 function theme_graphapi_dispatch($vars) {
   $engines = graphapi_views_formats();
-  $engine = '';
-  if (isset($vars['config']['engine'])) {
-    $engine = $vars['config']['engine'];
+  if (empty($engines)) {
+    graphapi_no_engines_found();
   }
+  $engine = isset($vars['config']['engine']) ? $vars['config']['engine'] : '';
   if (isset($engines[$engine])) {
     $theme = $engine . "_graphapi";
     return theme($theme, $vars);
   }
-  else {
-    if (!empty($engine)) {
-      return t("Graph API render engine !engine not found.", array('!engine' => $engine));
-    }
-    else {
-      graphapi_no_engine_founds();
-      return "";
-    }
+  elseif (!empty($engine)) {
+    return t("Graph API render engine !engine not found.", array('!engine' => $engine));
   }
+  return t("Graph API render engine not specified.");
 }
 
-function graphapi_no_engine_founds() {
+function graphapi_no_engines_found() {
   drupal_set_message(t('No Graph API render engines enabled. Check your !modules_page for a Graph API render engine.', array('!modules_page' => l(t('modules page'), 'admin/modules'))), 'warning');
 }
 
diff --git a/modules/graphapi_demo/graphapi_demo.module b/modules/graphapi_demo/graphapi_demo.module
index e5cb8d7..fa9ac18 100644
--- a/modules/graphapi_demo/graphapi_demo.module
+++ b/modules/graphapi_demo/graphapi_demo.module
@@ -32,16 +32,15 @@ function graphapi_demo_menu() {
 
 function graphapi_demo_page($engine = NULL) {
   $engines = graphapi_get_engines();
+  if (empty($engines)) {
+    graphapi_no_engines_found();
+  }
   if (is_null($engine) && count($engines)) {
     $engine = key($engines);
   }
   if (isset($engine)) {
     return graphapi_demo_engine($engine);
   }
-  else {
-    graphapi_no_engine_founds();
-    return "";
-  }
 }
 
 function graphapi_demo_engine($engine) {
