change to a better terrain algorithm