diff --git a/src/app/document/controllers/DocumentController.php b/src/app/document/controllers/DocumentController.php
index dff5497ac74ff795b3249dd936a5068fe48a9089..61d48e6cc6a4a81bb8090c6d854cf7900a20d704 100755
--- a/src/app/document/controllers/DocumentController.php
+++ b/src/app/document/controllers/DocumentController.php
@@ -316,7 +316,7 @@ class DocumentController
                 'data'  => [$args['id']]
             ]);
             if (empty($filePaths)) {
-                return $response->withStatus(500)->withJson(['errors' => 'No documents found on Docserver']);
+                return $response->withStatus(500)->withJson(['errors' => 'Document does not exist']);
             }
 
             $attachments = AttachmentModel::get([
@@ -333,20 +333,16 @@ class DocumentController
                 $filePaths = array_merge($filePaths, $attachmentFilePaths);
             }
 
-            foreach ($docServers as $docserver) {
-                foreach ($filePaths as $filePath) {
+            $docServers = array_column($docServers, 'path', 'type');
+            foreach ($filePaths as $filePath) {
+                $docFilePath = $docServers[$filePath['type']] . $filePath['path'];
 
-                    if ($docserver['type'] == $filePath['type']) {
-                        $docFilePath = "{$docserver['path']}{$filePath['path']}";
-
-                        if (file_exists("$docFilePath")) {
-                            AdrModel::deleteDocumentAdr([
-                                'where' => ['id = ?'],
-                                'data'  => [$filePath['id']]
-                            ]);
-                            unlink($docFilePath);
-                        }
-                    }
+                if (file_exists("$docFilePath")) {
+                    AdrModel::deleteDocumentAdr([
+                        'where' => ['id = ?'],
+                        'data'  => [$filePath['id']]
+                    ]);
+                    unlink($docFilePath);
                 }
             }