diff --git a/lib/template.php b/lib/template.php
index e6525ec6336c08dd96042d097e61acc39fad0284..fdd608fdc7af76485cee1dd0b8457db118c91b02 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -329,10 +329,16 @@ class OC_Template{
 		
 		if (is_file($root.'/'.$file)) {
 				$pathes = explode('/', $file);
-				if($type == 'cssfiles' && $root == OC::$APPSROOTS[0] && $in_app){
+				$in_root = false;
+				foreach(OC::$APPSROOTS as $app_root) {
+					if($root == $app_root['path']) {
+						$in_root = true;
+						break;
+					}
+				}
+				if($type == 'cssfiles' && $in_root && $in_app){
 						$app = $pathes[0];
 						unset($pathes[0]);
-// 						unset($pathes[1]);
 						$path = implode('/', $pathes);
 						$this->append( $type, OC_Helper::linkTo($app, $path));
 				}else{