diff --git a/api/polling/universitysync.php b/api/polling/universitysync.php
index d5ccb9a4016f5331f9c287d31a21ed25430e152a..c47c1273ac2aaa184444e9e992e25db7ad2217a3 100644
--- a/api/polling/universitysync.php
+++ b/api/polling/universitysync.php
@@ -11,64 +11,26 @@ $response = $soap->doRequest("getAllUniversities", null);
 $db = new Database();
 
 if ($response->return != null) {
-    if (is_array($response->return)) {
-        for ($i = 0; $i < count($response->return); $i++) {
-            $uni_name = $response->return[$i]->name;
-            $phpUniId = $response->return[$i]->phpUniId;
-            $restUniId = $response->return[$i]->restUniId;
-
-            if ($phpUniId == -1) {
-                $query = "SELECT * FROM university WHERE name = ?";
-                $stmt = $db->setSTMT($query);
-                mysqli_stmt_bind_param($stmt, "s", $uni_name);
-                $exec = mysqli_stmt_execute($stmt);
-                /* If there is this instance do a soap request*/
-                if ($exec) {
-                    $res = mysqli_stmt_get_result($stmt);
-                    $row = mysqli_fetch_array($res);
-                    $params = array("php_uni_id" => $row['university_id'], "rest_uni_id" => $restUniId);
-                    $response = $soap->doRequest("setPHPId", $params);
-                } else {
-                    /* Create the instance in PHP*/
-                    $query = "INSERT INTO university (name) VALUES ?";
-                    $stmt = $db->setSTMT($query);
-                    mysqli_stmt_bind_param($stmt, "s", $uni_name);
-                    $exec = mysqli_stmt_execute($stmt);
-                    if ($exec) {
-                        $id = mysqli_insert_id($db->getDatabase());
-                        $params = array("php_uni_id" => $id, "rest_uni_id" => $restUniId);
-                        $response = $soap->doRequest("setPHPId", $params);
-                    }
-                }
-            }
-        }
-    } else {
-        $uni_name = $response->return->name;
-        $phpUniId = $response->return->phpUniId;
-        $restUniId = $response->return->restUniId;
+    if (!is_array($response->return)) {
+        $response->return = array($response->return);
+    }
+    foreach ($response->return as $uni) {
+        $uni_name = $uni->name;
+        $phpUniId = $uni->phpUniId;
+        $restUniId = $uni->restUniId;
 
         if ($phpUniId == -1) {
-            $query = "SELECT * FROM university WHERE name = ?";
+            // Insert to database
+            $query = "INSERT INTO university (name) VALUES (?)";
             $stmt = $db->setSTMT($query);
             mysqli_stmt_bind_param($stmt, "s", $uni_name);
             $exec = mysqli_stmt_execute($stmt);
-            /* If there is this instance do a soap request*/
             if ($exec) {
-                $res = mysqli_stmt_get_result($stmt);
-                $row = mysqli_fetch_array($res);
-                $params = array("php_uni_id" => $row["university_id"], "rest_uni_id" => $restUniId);
+                $id = mysqli_insert_id($db->getDatabase());
+                $params = array("php_uni_id" => $id, "rest_uni_id" => $restUniId);
                 $response = $soap->doRequest("setPHPId", $params);
             } else {
-                /* Create the instance in PHP*/
-                $query = "INSERT INTO university (name) VALUES ?";
-                $stmt = $db->setSTMT($query);
-                mysqli_stmt_bind_param($stmt, "s", $uni_name);
-                $exec = mysqli_stmt_execute($stmt);
-                if ($exec) {
-                    $id = mysqli_insert_id($db->getDatabase());
-                    $params = array("php_uni_id" => $id, "rest_uni_id" => $restUniId);
-                    $response = $soap->doRequest("setPHPId", $params);
-                }
+                echo "Error: " . mysqli_error($db->getDatabase());
             }
         }
     }