Problem With Wandering Script and Terrain.SampleHieght

I have been trying to get a basic wandering script done for a project I have been working on. I got everything to work except my terrain.SampleHieght, when even I add it in it causes my object to go off indefinitely in one direction along the Z axis. Any advice is helpful and appreciated.

#pragma strict
var Speed = 3;
private var wayPoint : Vector3= Vector3.zero;
var circleSize = 20;
//variables speed, circlesize, and range of Vectors for waypoint

function Start()
{
    random();
}

function Update ()
{
transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime;




if ((transform.position - wayPoint).magnitude < 1)
{
//movement changes direction on approching a certain distance ot the waypoint
random();
} 
}
function random (){

var chooseWayPoint : Vector3 = Random.insideUnitSphere * (circleSize);
wayPoint.y = Terrain.activeTerrain.SampleHeight(wayPoint)+ Terrain.activeTerrain.GetPosition().y;
wayPoint = new Vector3 (chooseWayPoint.x, wayPoint.y, chooseWayPoint.z);

//set the sphere of allowed movement
transform.LookAt(wayPoint);

}

any success?