diff --git a/src/kode/Tournament.cpp b/src/kode/Tournament.cpp
index 80b74fd5c60ef34803028ed20e84eccbae6f36be..ed3eb7253a1cc25ace8cb77aab05479f7c77cf57 100644
--- a/src/kode/Tournament.cpp
+++ b/src/kode/Tournament.cpp
@@ -29,11 +29,14 @@ void Tournament::enterResults()
     cout << endl << "Enter results for round " << currentRound;
     for (int i = 0; i < nrOfTables; ++i)
     {
+        playerList[searchByID(white[i],playerList)]->playedAgainst.push_back( playerList[searchByID(black[i],playerList)]);
+        playerList[searchByID(black[i],playerList)]->playedAgainst.push_back(playerList[searchByID(white[i],playerList)]);
+        playerList[searchByID(white[i],playerList)]->white++;
         int answer;
         cout << endl << "Enter results for table " << i+1 << "with "
-        << playerList[searchByID(white[i],1)]->lastName
+        << playerList[searchByID(white[i],playerList)]->lastName
         << " as white and "
-        << playerList[searchByID(black[i],1)]->lastName
+        << playerList[searchByID(black[i],playerList)]->lastName
         << " as black."
         << endl << "1: white victory"
         << endl << "2: black victory"
@@ -42,16 +45,16 @@ void Tournament::enterResults()
         switch (answer)
         {
             case 1:
-                playerList[searchByID(white[i],1)]->results.push_back(2);
-                playerList[searchByID(black[i],1)]->results.push_back(0);
+                playerList[searchByID(white[i],playerList)]->results.push_back(2);
+                playerList[searchByID(black[i],playerList)]->results.push_back(0);
                 break;
             case 2:
-                playerList[searchByID(white[i],1)]->results.push_back(0);
-                playerList[searchByID(black[i],1)]->results.push_back(2);
+                playerList[searchByID(white[i],playerList)]->results.push_back(0);
+                playerList[searchByID(black[i],playerList)]->results.push_back(2);
                 break;
             case 3:
-                playerList[searchByID(white[i],1)]->results.push_back(1);
-                playerList[searchByID(black[i],1)]->results.push_back(1);
+                playerList[searchByID(white[i],playerList)]->results.push_back(1);
+                playerList[searchByID(black[i],playerList)]->results.push_back(1);
                 break;
             default:
                 cout << "Error!";
@@ -90,6 +93,7 @@ void Tournament::printTables()
 
     currentRound++;
 
+
     if (currentRound == 1)
     {
         vector<Player*> playersPlaying = playerList;
@@ -109,8 +113,8 @@ void Tournament::printTables()
     for (int i = 0; i < nrOfTables; ++i)
     {
         cout << endl << i << "\t\t"
-        << playerList[searchByID(white[i],1)]->lastName
-        << "\t\t" << playerList[searchByID(black[i],1)]->lastName;
+        << playerList[searchByID(white[i],playerList)]->lastName
+        << "\t\t" << playerList[searchByID(black[i],playerList)]->lastName;
     }
 }
 
@@ -126,6 +130,7 @@ void Tournament::createMatchups()
         currentPlayer = playersPlaying[0];
         for (int j = 0; j < playersPlaying.size(); j++) //finds the players opponent
         {
+
                 if (!currentPlayer->hasPlayedAgainst(playersPlaying[j]->playerID))
                 {
                     opponent=playersPlaying[j];
@@ -143,38 +148,15 @@ void Tournament::createMatchups()
                 }
 
         }
-        bool wasOneWhite;
-        bool wasTwoWhite;
-        for (int j = currentRound-2; j >= 0; j--) //decides who is white and who is black
+        if (currentPlayer->white > opponent->white || currentPlayer->white == opponent->white)
         {
-            wasOneWhite = currentPlayer->wasWhite[j];
-            wasTwoWhite = opponent->wasWhite[j];
-            if (wasOneWhite != wasTwoWhite)
-            {
-                if (wasOneWhite)
-                {
-                    white[i] = opponent->playerID;
-                    opponent->wasWhite.push_back(true);
-                    black[i] = currentPlayer->playerID;
-                    currentPlayer->wasWhite.push_back(false);
-                    j = 0; //exits loop
-                }
-                else if(wasTwoWhite)
-                {
-                    white[i] = currentPlayer->playerID;
-                    currentPlayer->wasWhite.push_back(true);
-                    black[i] = opponent->playerID;
-                    opponent->wasWhite.push_back(false);
-                    j = 0; //exits loop
-                }
-            }
-            if (j==0 && white.size()<=i) //if they have had the same color every round grant the lower player white
-            {
-                white[i] = opponent->playerID;
-                opponent->wasWhite.push_back(true);
-                black[i] = currentPlayer->playerID;
-                currentPlayer->wasWhite.push_back(false);
-            }
+            white.push_back(opponent->playerID);
+            black.push_back(currentPlayer->playerID);
+        }
+        else if (currentPlayer->white < opponent->white)
+        {
+            white.push_back(currentPlayer->playerID);
+            black.push_back(opponent->playerID);
         }
     }
 }
diff --git a/src/kode/deletePlayer.cpp b/src/kode/deletePlayer.cpp
index 416a43b855dc3b4140b12fc83e63b3b1ba5dd7e0..65c9ea8baf2b75366e77a28f084ecf68719bd024 100644
--- a/src/kode/deletePlayer.cpp
+++ b/src/kode/deletePlayer.cpp
@@ -43,12 +43,12 @@ void deletePlayer()
                 do
                 {
                     id = lesInt("\nPlease type the ID of the player you wish to delete\n",0,10000);
-                    index = searchByID(id,1);
+                    index = searchByID(id,playerList);
                     if (index == -1)
                     {
                         cout << endl << "No player with this ID exists, please try again!" << endl;
                     }
-                }while(searchByID(id,1)==-1);
+                }while(searchByID(id,playerList)==-1);
                 playerToDelete = playerList[index];
                 break;
             default:
diff --git a/src/kode/editPlayer.cpp b/src/kode/editPlayer.cpp
index 57b9ef25f14934e92595cdd28069126acef09bf0..135519a522241099cd480ab6bdef59392e23b178 100644
--- a/src/kode/editPlayer.cpp
+++ b/src/kode/editPlayer.cpp
@@ -48,12 +48,12 @@ void editPlayer()
                 do
                 {
                     id = lesInt("\nPlease type the ID of the player you wish to edit\n",0,10000);
-                    index = searchByID(id,1);
+                    index = searchByID(id,playerList);
                     if (index == -1)
                     {
                         cout << endl << "No player with this ID exists, please try again!" << endl;
                     }
-                }while(searchByID(id,1)==-1);
+                }while(searchByID(id,playerList)==-1);
                 playerToEdit = playerList[index];
                 break;
             default:
diff --git a/src/kode/functions.h b/src/kode/functions.h
index 3c71103317665118ac2f05eaea316aa2963b2340..519acd78f92a1b03a9dc4b77c5d4eaf1ceff1816 100644
--- a/src/kode/functions.h
+++ b/src/kode/functions.h
@@ -8,7 +8,7 @@
 using namespace std;
 
 void newPlayer(int id); //+
-int searchByID(int id, int list); //+
+int searchByID(int id, vector<Player*> list); //+
 int searchByName(string name); //+
 void sortRanking(); //+
 void printRanking(); //+
diff --git a/src/kode/newPlayer.cpp b/src/kode/newPlayer.cpp
index 9f1103207fd7cf63ac1a19c42a59168eab1920da..d45bf0af038d692d1af83410512684a497cbcd31 100644
--- a/src/kode/newPlayer.cpp
+++ b/src/kode/newPlayer.cpp
@@ -16,13 +16,13 @@ extern vector<Player*>playerList;
 void newPlayer(int id)
 {
     Player* newPlayer;
-    if (searchByID(id,1)!=-1)
+    if (searchByID(id,playerList)!=-1)
     {
         do
         {
             cout << endl << "A player with this ID already exists, please try again!" << endl;
             id = lesInt("Please offer a valid ID\n",0,10000);
-        }while(searchByID(id,1)!=-1);
+        }while(searchByID(id,playerList)!=-1);
     }
     newPlayer = new Player;
     newPlayer->playerID = id;
@@ -32,6 +32,7 @@ void newPlayer(int id)
     getline(cin, newPlayer->firstName);
     newPlayer->rating = lesInt("\nRating: ", 1, 3000);
     cout << endl << "Club: ";
+    newPlayer->white=0;
     getline(cin, newPlayer->club);
 
     playerList.push_back(newPlayer);
diff --git a/src/kode/player.cpp b/src/kode/player.cpp
index d6e4cbb2f7971a29218afd3f31adcc563bbbe5f7..eaf5d9f43e79dd412b4c928e827d55817f4febee 100644
--- a/src/kode/player.cpp
+++ b/src/kode/player.cpp
@@ -114,7 +114,7 @@ int Player::currentRank(int id)
 {
     int index;
     sortRanking();
-    index = searchByID(id,2);
+    index = searchByID(id,sortedRankings);
     if (index = -1)
     {
         cout << endl << "Error: no player found!" << endl;
@@ -137,8 +137,10 @@ int Player::currentRank(int id)
 
 bool Player::hasPlayedAgainst(int id)
 {
+
     for (int i = 0; i < playedAgainst.size(); i++)
     {
+
         if (playedAgainst[i]->playerID == id)
         {
             return true;
diff --git a/src/kode/player.h b/src/kode/player.h
index e7f577329c2fb24e4acd8b0e679e16670f566211..6d12e9a7ffe33675a614a2975bfbe4625de58b33 100644
--- a/src/kode/player.h
+++ b/src/kode/player.h
@@ -22,12 +22,12 @@ class Player
 
         int rating;
         int playerID;
+        int white;
 
         float score;
 
         vector <int> results;  //stores the results of each match, 0 for loss, 1 for draw and 2 for win
         vector <Player*> playedAgainst; //has every person they have played against
-        vector<bool> wasWhite; //true for each round the player had white pieces, false for black
 
         Player();
         Player(string name, string surName, string clubName, int rating, int playerID, float score);
diff --git a/src/kode/printRanking.cpp b/src/kode/printRanking.cpp
index 673cd52dd432cba93d99bf1b6236fedf292997fa..e022819854a72cbf089db7d2dc5cefd5c3358833 100644
--- a/src/kode/printRanking.cpp
+++ b/src/kode/printRanking.cpp
@@ -22,7 +22,7 @@ void printRanking()
     sortRanking();
         float currentScoreTP = sortedRankings[0]->score;
         int currentPlace = 1;
-        for (int i = 0; i < sortedRankings.size(); ++i)
+        for (int i = 0; i < sortedRankings.size(); i++)
         {
             if (currentScoreTP > sortedRankings[i]->score)
             {
diff --git a/src/kode/searchByID.cpp b/src/kode/searchByID.cpp
index 5f41d6d8b2c9ae447643828c22be168815b091a9..c3c9cde0fe0f4ed331533f0c385410b25b2dfdef 100644
--- a/src/kode/searchByID.cpp
+++ b/src/kode/searchByID.cpp
@@ -6,25 +6,12 @@
 extern vector<Player*> playerList;
 extern vector<Player*> sortedRankings;
 
-int searchByID(int id, int list)
+int searchByID(int id, vector<Player*> list)
 {
-    vector<Player*> listToUse;
-    if (list == 1)
-    {
-        listToUse=playerList;
-    }
-    else if (list == 2)
-    {
-        listToUse = sortedRankings;
-    }
-    else
-    {
-        cout << endl << "Unexpected error!" << endl;
-        return -1;
-    }
-    for (int i = 0; i < listToUse.size(); i++)
+
+    for (int i = 0; i < list.size(); i++)
     {
-        if (listToUse[i]->playerID == id)
+        if (list[i]->playerID == id)
         {
             return i;
         }
diff --git a/src/kode/sortRanking.cpp b/src/kode/sortRanking.cpp
index b48e9ffd72a5e466ad2f5cb9b93bef052a552e21..189ab1f36cbb5666a6211a14642169f4b105af7f 100644
--- a/src/kode/sortRanking.cpp
+++ b/src/kode/sortRanking.cpp
@@ -1,7 +1,7 @@
 #include <vector>   //  vector
-#include <iostream> //  cout, cin
 
 #include "player.h"
+#include "functions.h"
 
 using namespace std;
 
@@ -11,11 +11,11 @@ extern vector<Player*> sortedRankings;
 void sortRanking()
 {
     sortedRankings.clear();
-    float currentHigh = 0;
-    vector<Player *> listUnsorted = playerList;
-    vector<Player *> leadingPlayers;
+    float currentHigh;
+    vector<Player*> listUnsorted = playerList;
+    vector<Player*> leadingPlayers;
 
-    vector<int> listIndex;
+    vector<int> listIDs;
 
     do
     {
@@ -23,18 +23,18 @@ void sortRanking()
         for (int i = 0; i < listUnsorted.size(); i++)
         {
             listUnsorted[i]->calculateScore();
-          //  cout << endl << listUnsorted[i]->score << " : " << listUnsorted[i]->lastName;
             if (listUnsorted[i]->score > currentHigh)
             {
                 leadingPlayers.clear();
+                listIDs.clear();
                 leadingPlayers.push_back(listUnsorted[i]);
-                listIndex.push_back(i);
+                listIDs.push_back(listUnsorted[i]->playerID);
                 currentHigh = leadingPlayers[0]->score;
             }
             else if (listUnsorted[i]->score == currentHigh)
             {
                 leadingPlayers.push_back(listUnsorted[i]);
-                listIndex.push_back(i);
+                listIDs.push_back(listUnsorted[i]->playerID);
             }
         }
         for (int i = 0; i < leadingPlayers.size(); i++)
@@ -43,13 +43,11 @@ void sortRanking()
 
         }
         leadingPlayers.clear();
-        cout << listIndex.size();
-        for (int i = 0; i < listIndex.size(); ++i)
+        for (int i = 0; i < listIDs.size(); i++)
         {
-
-            listUnsorted[listIndex[i]] = listUnsorted[listUnsorted.size() - 1 - i];
+            listUnsorted[searchByID(listIDs[i],listUnsorted)] = listUnsorted[listUnsorted.size()-1];
             listUnsorted.pop_back();
         }
-        listIndex.clear();
+        listIDs.clear();
     } while (listUnsorted.size() > 0);
 }
\ No newline at end of file