implemented terrain function