diff --git a/advagg.module b/advagg.module
index 27880d0..9f6b98c 100644
--- a/advagg.module
+++ b/advagg.module
@@ -3283,18 +3283,16 @@ function advagg_js_array($external_no_preprocess, $output_preprocess, $output_no
  * Return the correct headers for advagg bundles.
  */
 function advagg_file_download($file, $type = '') {
-  if (strpos($file, '/advagg_') !== 0) {
+  if (strpos($file, '/advagg_') !== FALSE && !empty($type)) {
     $return = array(
       'Content-Length: ' . filesize($file),
       'Cache-Control: ' . 'max-age=31556926, public',
     );
-    if (!empty($type)) {
-      if ($type == 'css') {
-        $return[] = 'Content-Type: text/css';
-      }
-      if ($type == 'js') {
-        $return[] = 'Content-Type: text/javascript';
-      }
+    if ($type == 'css') {
+      $return[] = 'Content-Type: text/css';
+    }
+    if ($type == 'js') {
+      $return[] = 'Content-Type: text/javascript';
     }
     return $return;
   }
