diff --git a/advagg_mod/advagg_mod.module b/advagg_mod/advagg_mod.module
index 4add3b7..ab4ea29 100644
--- a/advagg_mod/advagg_mod.module
+++ b/advagg_mod/advagg_mod.module
@@ -1172,12 +1172,15 @@ function advagg_mod_js_move_to_footer(array &$js) {
       }
     }
 
+    if (!isset($values['scope'])) {
+      $values['group'] = 0;
+    }
     // If JS is not in the header increase group by 10000.
-    if ($values['scope'] !== 'header') {
+    if (!isset($values['scope']) || $values['scope'] !== 'header') {
       $values['group'] += 10000;
     }
     // If JS is already in the footer increase group by 10000.
-    if ($values['scope'] === 'footer') {
+    if (isset($values['scope']) && $values['scope'] === 'footer') {
       $values['group'] += 10000;
     }
     $values['scope'] = 'footer';
