diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 15fbda927e0fde8e1040974ff02875d690d1f7d5..9906b7670a8219e85f997fc88358f2547f3f8b93 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -400,19 +400,11 @@ class OC_Mount_Config {
 				'options' => self::encryptPasswords($classOptions))
 			)
 		);
+
 		$mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
-		// Merge the new mount point into the current mount points
-		if (isset($mountPoints[$mountType])) {
-			if (isset($mountPoints[$mountType][$applicable])) {
-				$mountPoints[$mountType][$applicable]
-					= array_merge($mountPoints[$mountType][$applicable], $mount[$applicable]);
-			} else {
-				$mountPoints[$mountType] = array_merge($mountPoints[$mountType], $mount);
-			}
-		} else {
-			$mountPoints[$mountType] = $mount;
-		}
+		$mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType);
 		self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
+
 		return self::getBackendStatus($class, $classOptions, $isPersonal);
 	}
 
@@ -689,6 +681,28 @@ class OC_Mount_Config {
 		return $cipher->decrypt($binaryPassword);
 	}
 
+	/**
+	 * Merges mount points
+	 * @param array $data Existing mount points
+	 * @param array $mountPoint New mount point
+	 * @param string $mountType
+	 * @return array
+	 */
+	private static function mergeMountPoints($data, $mountPoint, $mountType) {
+		$applicable = key($mountPoint);
+		if (isset($data[$mountType])) {
+			if (isset($data[$mountType][$applicable])) {
+				$data[$mountType][$applicable]
+					= array_merge($data[$mountType][$applicable], $mountPoint[$applicable]);
+			} else {
+				$data[$mountType] = array_merge($data[$mountType], $mountPoint);
+			}
+		} else {
+			$data[$mountType] = $mountPoint;
+		}
+		return $data;
+	}
+
 	/**
 	 * Returns the encryption cipher
 	 */