generate grass on terrain only when there's no slope

Hello,

I try to generate terrain grass using script based on weather there’s a slope or not (slope = no grass, flat surface = grass). I thought it should be simple but for some reason my code doesn’t work. I tried two things, first I tried this:

		int[,] grass = new int[resolution+1, resolution+1]; 
		for (int x = 0; x <= resolution; ++x) {
			for (int y = 0; y <= resolution; ++y) {
				
				float steepness = terrain_data.GetInterpolatedNormal((float)x / (float)resolution, (float)y / (float)resolution).y;

				if (steepness > 0.9f)
					grass[x,y] = Random.Range(0, 2);
				else
					grass[x,y] = 0;
			}
		}

but for some reason I’m getting some heavy slopes with grass on them. then I tried using Abs(GetSteepness()), but again, there are some surfaces that should have grass and remain empty and some clear slopes that should be empty but end up with grass on them.

what am I doing wrong?

thanks!

added illustration pic:

GetInterpolatedNormal returns Vector3, so I’m a little surprised 5 doesn’t generate an error? If that’s the issue, then it would be if (steepness.y > …) on line 8