void initialization()
        {
            redScore  = 0;
            blueScore = 0;
            for (int i = 0; i < 6; i++)
            {
                teamView [i] = new ScrollView();

                pitInfo[i] = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                };
                if (i < 3)
                {
                    pitInfo [i].BackgroundColor = Color.Maroon;
                }
                else
                {
                    pitInfo [i].BackgroundColor = Color.Teal;
                }

                for (int j = 0; j < 99; j++)
                {
                    descriptionLabel [i, j] = new Label {
                        FontSize  = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        TextColor = Color.White
                    };
                    dataLabel [i, j] = new Label()
                    {
                        FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
                    };
                }
                defGrid [i] = new Grid()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.Black,
                    ColumnSpacing     = 1,
                    RowSpacing        = 1,

                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                    },
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                    }
                };
                shotGrid[i] = new Grid()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.Black,
                    ColumnSpacing     = 1,
                    RowSpacing        = 1,

                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        },
                    },
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                        new RowDefinition {
                            Height = new GridLength(20, GridUnitType.Absolute)
                        },
                    }
                };

                defHeaderCells [i, 0]              = new ColumnHeaderCellSmall();
                defHeaderCells [i, 0].header.Text  = "Stall";
                defHeaderCells [i, 1]              = new ColumnHeaderCellSmall();
                defHeaderCells [i, 1].header.Text  = "Pass";
                defHeaderCells [i, 2]              = new ColumnHeaderCellSmall();
                defHeaderCells [i, 2].header.Text  = "Tries";
                defHeaderCells [i, 3]              = new ColumnHeaderCellSmall();
                defHeaderCells [i, 3].header.Text  = "Faced";
                shotHeaderCells [i, 0]             = new ColumnHeaderCellSmall();
                shotHeaderCells [i, 0].header.Text = "Made";
                shotHeaderCells [i, 1]             = new ColumnHeaderCellSmall();
                shotHeaderCells [i, 1].header.Text = "Tried";
                shotHeaderCells [i, 2]             = new ColumnHeaderCellSmall();
                shotHeaderCells [i, 2].header.Text = "%";
            }
            for (int i = 0; i < 20; i++)
            {
                rowHeaderLabels [i] = new Label()
                {
                    FontSize  = GlobalVariables.sizeSmall,
                    TextColor = Color.White
                }
            }
            ;

            addRowHeaders("Red Total:");
            addRowHeaders("test");
            addRowHeaders("Blue Total:");
            addRowHeaders("test");
            addRowHeaders(" ");
            addRowHeaders("Low Bar ");
            addRowHeaders("Port");
            addRowHeaders("Cheval");
            addRowHeaders("Moat");
            addRowHeaders("Ramp");
            addRowHeaders("Draw");
            addRowHeaders("Sally");
            addRowHeaders("Rock");
            addRowHeaders("Rough");
            addRowHeaders(" ");
            addRowHeaders("High");
            addRowHeaders("Low");
        }

        void addRowHeaders(string description)
        {
            if (rowHeaders == 2)
            {
                rowHeaderLabels [rowHeaders].Text = "0";
            }
            else if (rowHeaders == 4)
            {
                rowHeaderLabels [rowHeaders].Text = "0";
            }
            else
            {
                rowHeaderLabels [rowHeaders].Text = description;
            }
            rowHeaderGrid.Children.Add(rowHeaderLabels [rowHeaders], 0, rowHeaders);
            rowHeaders++;
        }

        void calculateAllianceScore(ParseObject tData, int arrayIndex)
        {
            if (arrayIndex < 3)
            {
                redScore += Convert.ToDouble(tData ["avgScore"]);
                rowHeaderLabels [2].Text = String.Format("{0:N2}", redScore);
            }
            else
            {
                blueScore += Convert.ToInt16(tData ["avgScore"]);
                rowHeaderLabels [4].Text = String.Format("{0:N2}", blueScore);
            }
        }

        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 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 addRobotImage(ParseObject teamData, int arrayIndex)
        {
            try {
                if (teamData ["robotImage"].ToString() != null)
                {
                    ParseFile robotImageURL = (ParseFile)teamData ["robotImage"];
                    //Gets the image from parse and converts it to ParseFile

                    robotImage[arrayIndex] = new CachedImage()
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                        Source            = new UriImageSource {
                            Uri            = robotImageURL.Url,
                            CachingEnabled = true,
                            CacheValidity  = new TimeSpan(7, 0, 0, 0)                         //Caches Images onto your device for a week
                        },
                        HeightRequest        = 120,
                        DownsampleToViewSize = true
                    };
                    robotImageFull[arrayIndex] = new CachedImage()
                    {
                        Source = new UriImageSource {
                            Uri            = robotImageURL.Url,
                            CachingEnabled = true,
                            CacheValidity  = new TimeSpan(7, 0, 0, 0)                         //Caches Images onto your device for a week
                        }
                    };

                    TapGestureRecognizer tap = new TapGestureRecognizer();
                    tap.Tapped += (object sender, EventArgs e) => {
                        // Create a gesture recognizer to display the popup image
                        popUpPage(robotImageFull[arrayIndex]);
                    };
                    robotImage[arrayIndex].GestureRecognizers.Add(tap);
                    robotImage[arrayIndex].Aspect = Aspect.AspectFit;
                }
                else
                {
                }
            }
            catch {
                robotImage[arrayIndex].Source = "Placeholder_image_placeholder.png";
            }

            headerGrid.Children.Add(robotImage[arrayIndex], 2 * arrayIndex, 2 * (arrayIndex + 1), 1, 2);
        }

        async void popUpPage(CachedImage rImage)
        {
            await Task.Yield();

            await PopupNavigation.PushAsync(new ImagePopupPage (rImage), false);
        }

        async void refreshPage()
        {
            busyIcon.IsVisible = true;
            busyIcon.IsRunning = true;

            for (int i = 0; i < 6; i++)
            {
                new CalculateAverageData(teamNumber[i]);
                ParseQuery <ParseObject> refresh = ParseObject.GetQuery("TeamData");
                ParseQuery <ParseObject> sorted  = refresh.WhereEqualTo("teamNumber", teamNumber[i]);

                var allTeams = await sorted.FindAsync();

                foreach (ParseObject obj in allTeams)
                {
                    teamData [i] = obj;
                }
            }

            PopulateData(data);

            busyIcon.IsVisible = false;
            busyIcon.IsRunning = false;
        }
    }
		void initialization(){
			redScore = 0;
			blueScore = 0;
			for (int i = 0; i < 6; i++) {
				
				teamView [i] = new ScrollView ();

				pitInfo[i] = new StackLayout () {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					VerticalOptions = LayoutOptions.FillAndExpand,
				};
				if (i < 3)
					pitInfo [i].BackgroundColor = Color.Maroon;
				else
					pitInfo [i].BackgroundColor = Color.Teal;
				
				for (int j = 0; j < 99; j++) {
					descriptionLabel [i, j] = new Label {
						FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
						TextColor = Color.White
					};
					dataLabel [i, j] = new Label () {
						FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label))
					};
				}
				defGrid [i] = new Grid () {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					BackgroundColor = Color.Black,
					ColumnSpacing = 1,
					RowSpacing = 1,

					ColumnDefinitions = {
						new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
						new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
						new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
						new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
					},
					RowDefinitions = {
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
						new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute) },
					}
				};
				shotGrid[i] = new Grid(){
						HorizontalOptions = LayoutOptions.FillAndExpand,
						BackgroundColor = Color.Black,
						ColumnSpacing = 1,
						RowSpacing = 1,

						ColumnDefinitions = {
							new ColumnDefinition{ Width = new GridLength(1, GridUnitType.Star) },
							new ColumnDefinition{ Width = new GridLength(1, GridUnitType.Star) },
							new ColumnDefinition{ Width = new GridLength(1, GridUnitType.Star) },
							new ColumnDefinition{ Width = GridLength.Auto },
						},
						RowDefinitions = {
							new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute)},
							new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute)},
							new RowDefinition { Height = new GridLength (20, GridUnitType.Absolute)},
						}
				};
				
				defHeaderCells [i, 0] = new ColumnHeaderCellSmall ();
				defHeaderCells [i, 0].header.Text = "Stall";
				defHeaderCells [i, 1] = new ColumnHeaderCellSmall ();
				defHeaderCells [i, 1].header.Text = "Pass";
				defHeaderCells [i, 2] = new ColumnHeaderCellSmall ();
				defHeaderCells [i, 2].header.Text = "Tries";
				defHeaderCells [i, 3] = new ColumnHeaderCellSmall ();
				defHeaderCells [i, 3].header.Text = "Faced";
				shotHeaderCells [i, 0] = new ColumnHeaderCellSmall ();
				shotHeaderCells [i, 0].header.Text = "Made";
				shotHeaderCells [i, 1] = new ColumnHeaderCellSmall ();
				shotHeaderCells [i, 1].header.Text = "Tried";
				shotHeaderCells [i, 2] = new ColumnHeaderCellSmall ();
				shotHeaderCells [i, 2].header.Text = "%";
			}
			for (int i = 0; i < 20; i++)
				rowHeaderLabels [i] = new Label () {
					FontSize = GlobalVariables.sizeSmall,
				TextColor = Color.White
				};

			addRowHeaders ("Red Total:");
			addRowHeaders ("test");
			addRowHeaders ("Blue Total:");
			addRowHeaders ("test");
			addRowHeaders (" ");
			addRowHeaders ("Low Bar ");
			addRowHeaders ("Port");
			addRowHeaders ("Cheval");
			addRowHeaders ("Moat");
			addRowHeaders ("Ramp");
			addRowHeaders ("Draw");
			addRowHeaders ("Sally");
			addRowHeaders ("Rock");
			addRowHeaders ("Rough");
			addRowHeaders (" ");
			addRowHeaders ("High");
			addRowHeaders ("Low");
		}