diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php
index 5b77a46dc7a7a026b313f8b6c8e5e9484018dd7d..907a90352ea6d5cc1237f601d5ed5bdb73f68e90 100644
--- a/modules/metarefresh/lib/MetaLoader.php
+++ b/modules/metarefresh/lib/MetaLoader.php
@@ -186,9 +186,11 @@ class sspmod_metarefresh_MetaLoader {
 		}
 	
 		if(!file_exists($outputDir)) {
-			if (!is_writable($outputDir)) throw new Exception('Permission denied creating directory: ' . $outputDir);
 			SimpleSAML_Logger::info('Creating directory: ' . $outputDir . "\n");
-			mkdir($outputDir, 0777, TRUE);
+			$res = @mkdir($outputDir, 0777, TRUE);
+			if ($res === FALSE) {
+				throw new Exception('Error creating directory: ' . $outputDir);
+			}
 		}
 	
 		foreach($this->metadata as $category => $elements) {