Random biome generation for unity 2d

hello so i am trying to create a random biome generation system for my game but whenever it generates a snow tile it doesnt stop and permanantly changes it for the rest of the generation. here is my current code but any help would be appreciated:

public class ProceduralGeneration : MonoBehaviour
{
    [SerializeField] int width,height;
    [SerializeField] int minStoneheight, maxStoneHeight;
    [SerializeField] GameObject dirt,grass,stone, snow,oldGrass;
    private int treeChance = 10;
    private int snowBiomeChance = 5;
    private int snowBiomeLength = 0;
    [SerializeField] private GameObject tree;
    void Start()
    {
        Generation();
    }

   public void Generation()
  {
        for (int x = 0; x < width; x++)//This will help spawn a tile on the x axis
        {
            // now for procedural generation we need to gradually increase and decrease the height value
            int minHeight = height - 1;
            int maxHeight = height + 2;
            height = Random.Range(minHeight, maxHeight);
            int minStoneSpawnDistance = height - minStoneheight;
            int maxStoneSpawnDistance = height - maxStoneHeight;
            int totalStoneSpawnDistance = Random.Range(minStoneSpawnDistance, maxStoneSpawnDistance);
            //Perlin noise.
            for (int y = 0; y < height; y++)//This will help spawn a tile on the y axis
            {
                if (y < totalStoneSpawnDistance)
                {
                    spawnObj(stone, x, y);
                }
                else
                {
                    spawnObj(dirt, x, y);
                }
               
            }
            if(totalStoneSpawnDistance == height)
            {
                spawnObj(stone, x, height);
            }
            else
            {
                spawnObj(grass, x, height);
                int t = Random.Range(1, treeChance);

                if (t == 1)
                {
                    //generate a tree
                         spawnObj(tree, x, height + 2);
                }
                   
                     int s = Random.Range(1, snowBiomeChance);
            if (s == 1)
            {
                grass = snow;
                snowBiomeLength = snowBiomeLength + 1;
            }
               if (snowBiomeLength <= 10)
               grass = oldGrass;
               snowBiomeLength = 0;
            }
           
            
        }
    }
    
    void spawnObj(GameObject obj,int width,int height)//What ever we spawn will be a child of our procedural generation gameObj
    {
        obj = Instantiate(obj, new Vector2(width, height), Quaternion.identity);
        obj.transform.parent = this.transform;
    }


    public void Reload()
    {
        
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
         
       
}



}

Line 57 assigns snow to grass.

If that isn’t it, well, sounds like you wrote a bug… and that means… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Also, please use the 2D tag only when you’re asking about a 2D feature please. Your question here is a pure scripting question so the “Scripting” tag is appropriate. Note that there is no such thing as “Unity 2D”.

Thanks.

thanks, i’ll try this out and see if it works