void addShotItems(string shot, ParseObject tData, int arrayIndex, int gridHieght){
			DataCell cell1 = new DataCell ();
			DataCell cell2 = new DataCell ();
			DataCell cell3 = new DataCell ();
			cell1.data.TextColor = Color.White;
			cell2.data.TextColor = Color.White;
			cell3.data.TextColor = Color.White;
			if (arrayIndex < 3) {
				cell1.BackgroundColor = Color.Red;
				cell2.BackgroundColor = Color.Red;
				cell3.BackgroundColor = Color.Red;
			} else {
				cell1.BackgroundColor = Color.Blue;
				cell2.BackgroundColor = Color.Blue;
				cell3.BackgroundColor = Color.Blue;
			}
			try{
				cell1.data.Text = tData[shot+"Successes"].ToString();
			}
			catch{
				cell1.data.Text = "NULL";
			}
			shotGrid [arrayIndex].Children.Add (cell1, 0, gridHieght);
			try{
				cell2.data.Text = tData[shot+"Total"].ToString();
			}
			catch{
				cell2.data.Text = "NULL";
			}
			shotGrid [arrayIndex].Children.Add (cell2, 1, gridHieght);
			try{
				cell3.data.Text = string.Format("{0:P}", tData[shot+"Accuracy"]);
			}
			catch{
				cell3.data.Text = "NULL";
			}
			shotGrid [arrayIndex].Children.Add (cell3, 2, gridHieght);
		}
		void addDefItems(string defense, ParseObject tData, int arrayIndex, int gridHieght){
			DataCell cell1 = new DataCell ();
			DataCell cell2 = new DataCell ();
			DataCell cell3 = new DataCell ();
			DataCell cell4 = new DataCell ();
			cell1.data.TextColor = Color.White;
			cell2.data.TextColor = Color.White;
			cell3.data.TextColor = Color.White;
			cell4.data.TextColor = Color.White;
			if (arrayIndex < 3) {
				cell1.BackgroundColor = Color.Red;
				cell2.BackgroundColor = Color.Red;
				cell3.BackgroundColor = Color.Red;
				cell4.BackgroundColor = Color.Red;
			} else {
				cell1.BackgroundColor = Color.Blue;
				cell2.BackgroundColor = Color.Blue;
				cell3.BackgroundColor = Color.Blue;
				cell4.BackgroundColor = Color.Blue;
			}
			try{
				cell1.data.Text = tData[defense+"sta"].ToString();
			}
			catch{
				cell1.data.Text = "NULL";
			}
			defGrid [arrayIndex].Children.Add (cell1, 0, gridHieght);
			try{
				cell2.data.Text = tData[defense].ToString();
			}
			catch{
				cell2.data.Text = "NULL";
			}
			defGrid [arrayIndex].Children.Add (cell2, 1, gridHieght);
			try{
				cell3.data.Text = tData[defense+"att"].ToString();
			}
			catch{
				cell3.data.Text = "NULL";
			}
			defGrid [arrayIndex].Children.Add (cell3, 2, gridHieght);
			try{
				cell4.data.Text = tData[defense+"count"].ToString();
			}
			catch{
				cell4.data.Text = "N";
			}
			defGrid [arrayIndex].Children.Add (cell4, 3, gridHieght);
		}
		void addColumnData(ParseObject data, string parseString, int arrayIndex){
			DataCell cell = new DataCell ();
			cell.data.TextColor = Color.White;
			try{
				cell.data.Text = data[parseString].ToString();
				if(data[parseString].ToString() == teamNumber.ToString()){
					cell.data.TextColor = Color.Lime;
					cell.data.FontSize = GlobalVariables.sizeTitle;
					cell.data.FontAttributes = FontAttributes.Bold;
				}
			}
			catch{
				cell.data.Text = "NULL";
			}
			if (gridX == 1)
				cell.BackgroundColor = Color.Olive;
			if (gridY % 2 == 1 && gridX < 5 && gridX != 1)
				cell.BackgroundColor = Color.Maroon;
			else if (gridY % 2 == 1 && gridX > 4)
				cell.BackgroundColor = Color.Teal;
			if (gridY % 2 == 0 && gridX < 5 && gridX != 1)
				cell.BackgroundColor = Color.Red;
			else if (gridY % 2 == 0 && gridX > 4)
				cell.BackgroundColor = Color.Blue;

			if (arrayIndex == 0) {
				TapGestureRecognizer tap = new TapGestureRecognizer ();
				tap.Tapped += (object sender, EventArgs e) => {
					if (new CheckInternetConnectivity().InternetStatus())
						Navigation.PushModalAsync (new MatchInfoDisplayPage (data));
				};
				cell.GestureRecognizers.Add (tap);
			}

			matchGrid.Children.Add (cell, arrayIndex, gridY);


			busyIcon.IsVisible = false;
			busyIcon.IsRunning = false;
		}
		async void addTeamData(int getTeamNumber, int arrayIndex){

			dataGrid.Children.Clear ();
			pitInfo [arrayIndex].Children.Clear ();

			ParseQuery<ParseObject> query = ParseObject.GetQuery ("TeamData");
			ParseQuery<ParseObject> findTeam = query.WhereEqualTo ("teamNumber", getTeamNumber);	
			var teamObj = await findTeam.FindAsync();
			foreach (ParseObject team in teamObj) {
				teamData[arrayIndex] = team;
			}
			DataCell avgScoreCell = new DataCell ();
			avgScoreCell.data.TextColor = Color.White;
			if (arrayIndex < 3)
				avgScoreCell.BackgroundColor = Color.Red;
			else
				avgScoreCell.BackgroundColor = Color.Blue;
			try{
				avgScoreCell.data.Text = String.Format("{0:N2}", teamData[arrayIndex]["avgScore"]);
			}
			catch{
				avgScoreCell.data.Text = "NULL";
			}
			headerGrid.Children.Add (avgScoreCell, 2*arrayIndex + 1, 0);


			calculateAllianceScore (teamData[arrayIndex], arrayIndex);

			Z = 0;
			gridHieght = 0;

			// Add team data, should be similar to RobotInfoViewPage
			addRobotImage(teamData[arrayIndex], arrayIndex);
			defGrid [arrayIndex].Children.Add (defHeaderCells [arrayIndex,0], 0, gridHieght);
			defGrid [arrayIndex].Children.Add (defHeaderCells [arrayIndex,1], 1, gridHieght);
			defGrid [arrayIndex].Children.Add (defHeaderCells [arrayIndex,2], 2, gridHieght);
			defGrid [arrayIndex].Children.Add (defHeaderCells [arrayIndex,3], 3, gridHieght++);
			//shotGrid [arrayIndex].Children.Add (avgScoreCell, 1, gridHieght++);
			addDefItems ("E", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("A1", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("A2", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("B1", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("B2", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("C1", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("C2", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("D1", teamData [arrayIndex], arrayIndex, gridHieght++);
			addDefItems ("D2", teamData [arrayIndex], arrayIndex, gridHieght++);
			//listedItem("Low Bar Successes:", "E", teamData[arrayIndex], arrayIndex);
			//listedItem("Average Score:", "avgScore", teamData[arrayIndex], arrayIndex);
			//listedItem("Portcullis Successes:", "A1", teamData[arrayIndex], arrayIndex);
			//listedItem("Cheval de Frise Sccesses:", "A2", teamData[arrayIndex], arrayIndex);
			//listedItem("Moat Successes:", "B1", teamData[arrayIndex], arrayIndex);
			//listedItem("Rampart Successes:", "B2", teamData[arrayIndex], arrayIndex);
			//listedItem("Drawbridge Successes:", "C1", teamData[arrayIndex], arrayIndex);
			//listedItem("Sally Port Successes:", "C2", teamData[arrayIndex], arrayIndex);
			//listedItem("Rock Wall Successes:", "D1", teamData[arrayIndex], arrayIndex);
			//listedItem("Rough Terrain Successes:", "D2", teamData [arrayIndex], arrayIndex);


			gridHieght = 0;
			shotGrid [arrayIndex].Children.Add (shotHeaderCells [arrayIndex,0], 0, gridHieght);
			shotGrid [arrayIndex].Children.Add (shotHeaderCells [arrayIndex,1], 1, gridHieght);
			shotGrid [arrayIndex].Children.Add (shotHeaderCells [arrayIndex,2], 2, gridHieght++);

			addShotItems ("teleOpHigh", teamData [arrayIndex], arrayIndex, gridHieght++);
			addShotItems ("teleOpLow", teamData [arrayIndex], arrayIndex, gridHieght++);

			//listedItem("Total High Goal Acc", "totalTeleOpHighAccuracy", teamData[arrayIndex], arrayIndex);
			//listedItem("Best High Goal Acc", "bestTeleOpHighAccuracy", teamData[arrayIndex], arrayIndex);
			//listedItem("Total Low Goal Acc", "totalTeleOpLowAccuracy", teamData[arrayIndex], arrayIndex);
			//listedItem("Best Low Goal Acc", "bestTeleOpLowAccuracy", teamData[arrayIndex], arrayIndex);

			//listedItem ("Drive Train:", "driveType", teamData[arrayIndex], arrayIndex);
			listedItem ("Can LowBar: ", "lowBarAccess", teamData[arrayIndex], arrayIndex);
			//listedItem ("Intake Position:", "intakePos", teamData[arrayIndex], arrayIndex);
			listedItem ("Notes:", "notes", teamData[arrayIndex], arrayIndex);
			//listedItem ("Match Notes:", "matchNotes", teamData[arrayIndex], arrayIndex);

			teamView [arrayIndex].Content = pitInfo [arrayIndex];
			statsGrid.Children.Add (defGrid [arrayIndex], arrayIndex, 0);
			statsGrid.Children.Add (shotGrid [arrayIndex], arrayIndex, 1);
			dataGrid.Children.Add (teamView [arrayIndex], arrayIndex, 0);
		}
		void addColumnData(ParseObject data, string parseString, int arrayIndex){
			DataCell cell = new DataCell ();
			try{
				cell.data.Text = data[parseString].ToString();
			}
			catch{
				cell.data.Text = "NULL";
			}

			if (gridY % 2 == 1)
				cell.BackgroundColor = Color.Gray;

			dataGrid.Children.Add (cell, arrayIndex, gridY);
		}