implement terrainFunction