private void SpawnBuilding(float?maxHeight = null)
    {
        Debug.Log("spawn");
        Building buildingPrefab = buildings[Random.Range(0, buildings.Length)];

        if (currentBuildingNumber != 1)
        {
            Debug.Log("going to danger");
            if (maxHeight != null)
            {
                while (true)
                {
                    bool buildingsHeightDifferenceNotTooHigh = Building.AbsoluteHeightDifference(buildingPrefab, createdBuildings[currentBuildingNumber - 2]) < maxDifferenceBetweenBuildings;
                    bool isBelowMaxHeight = buildingPrefab.height < maxHeight;

                    if (buildingPrefab.hasWindows && buildingsHeightDifferenceNotTooHigh)
                    {
                        break;
                    }
                    else if (!buildingPrefab.hasWindows && Mathf.Abs((float)maxHeight - buildingPrefab.height) < maxDifferenceBetweenBuildings)
                    {
                        break;
                    }

                    buildingPrefab = buildings[Random.Range(0, buildings.Length)];
                }

                for (int i = 0; i < buildings.Length; i++)
                {
                    bool isBelowMaxHeight      = buildings[i].height < buildingPrefab.height;
                    bool isCloserFromMaxHeight = Mathf.Abs(buildings[i].height - (float)maxHeight) < Mathf.Abs(buildingPrefab.height - (float)maxHeight);

                    if (buildingPrefab.height > maxHeight && isBelowMaxHeight)
                    {
                        buildingPrefab = buildings[i];
                    }
                    else if (isBelowMaxHeight && isCloserFromMaxHeight)
                    {
                        buildingPrefab = buildings[i];
                    }
                }
                Debug.Log("prefab :" + buildingPrefab.name);
            }
            else
            {
                bool buildingNotTooHigh = (createdBuildings[currentBuildingNumber - 2].height - buildingPrefab.height) >= -maxDifferenceBetweenBuildings;
                if (!buildingPrefab.hasWindows || buildingNotTooHigh)
                {
                    while (true)
                    {
                        Debug.Log("crash crash crash");
                        if (Input.GetKeyDown(KeyCode.A))
                        {
                            break;
                        }
                        buildingPrefab     = buildings[Random.Range(0, buildings.Length)];
                        buildingNotTooHigh = (createdBuildings[currentBuildingNumber - 2].height - buildingPrefab.height) >= -maxDifferenceBetweenBuildings;
                        if (buildingNotTooHigh || buildingPrefab.hasWindows)
                        {
                            break;
                        }
                    }
                }
            }
            Debug.Log("out of danger");
        }

        Building building = Instantiate(buildingPrefab, new Vector2(spawnPosition, 0), Quaternion.identity, buildingsParent);

        building.name = "Building " + currentBuildingNumber.ToString() + "( " + buildingPrefab.name + " )";

        // Decide if we want obstacles on this building
        if (Random.Range(0, 2) == 0 && currentBuildingNumber != 1)
        {
            // Spawn some obstacles on the building
            SpawnObstacles(new Vector2(spawnPosition + minDistanceBetweenEdgesAndObstacles, spawnPosition + building.width - minDistanceBetweenEdgesAndObstacles), building.height, currentBuildingNumber, obstaclesParent);
        }

        // Decide if we want an enemy on this building
        if (Random.Range(0, 3) == 0)
        {
            Instantiate(enemyPrefab,
                        new Vector2(spawnPosition + building.width - distanceBetweenEdgeAndEnemy, building.height),
                        Quaternion.identity,
                        enemiesParent);
        }

        // Decide if we want a hole
        // If yes push the next building spawn position even more
        if (Random.Range(0, 2) == 0) // temp
        {
            spawnPosition += Random.Range(holeSizeMinMax.x, holeSizeMinMax.y);
        }

        // Pushing next building spawn position
        spawnPosition += building.width;
        currentBuildingNumber++;
        createdBuildings.Add(building);
    }