terrain script cleaned up