public static void Main(String[] args)
        {
            //StartClient();
            int latency=00;

            //string myString = latency.ToString();

            Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sock.Connect (new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1234));
            BinaryFormatter bf1 = new BinaryFormatter ();
            MemoryStream ms1 = new MemoryStream ();
            bf1.Serialize (ms1, latency);

            sock.Send (ms1.ToArray());
            sock.Close ();
            Start();
            Thread mythread=new Thread(ConstantFetch);
            mythread.Start();
            Thread DeleteThread = new Thread (DeleteSomeTargets);
            DeleteThread.Start ();
            Thread lmythread=new Thread(updatelocation);
            lmythread.Start();
            Thread vmythread=new Thread(updatevelocity);
            vmythread.Start();
            //return 0;
            double sum=0;

            for (int i = 0; i < 30; i++) {// Change here

                Random rn = new Random ();

                Thread.Sleep (rn.Next(300,1200));
                int targ = closeSee ();
                if (idMap.ContainsKey(targ))
                {
                    sum=sum+0;
                    Console.WriteLine("Doing Good");
                }
                else{
                    Console.WriteLine ("Doing Bad");
                    Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    socket.Connect (new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1234));
                    FetchQuery2 fq = new FetchQuery2(new float[]{objectX[targ],objectY[targ]});
                    fq.targetId = targ;
                    BinaryFormatter bf = new BinaryFormatter ();
                    MemoryStream ms = new MemoryStream ();
                    bf.Serialize (ms, fq);
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    socket.Send (ms.ToArray());

                    byte[] instream = new byte[100000];
                    socket.Receive (instream);
                    ms = new MemoryStream (instream);
                    object obj2 = bf.Deserialize (ms);

                    if (obj2 is ObjectResult2) {
                        if (obj2 == null)
                            Console.WriteLine ("Null returned");
                        sw.Stop();
                        TimeSpan time= sw.Elapsed;
                        sum = sum + time.TotalSeconds;
                    }
                    socket.Close();
                }
                double average = sum / (i + 1);
                //Console.WriteLine ("Average fetching time={0}", average);

            }
            stop = 1;
            double aver = sum / 30;
            Console.WriteLine ("Average fetching time={0}", aver);
        }
 AskObject[] FetchObject2(FetchQuery2 fetchQuery)
 {
     float[] centerPoint = fetchQuery.centerPoint;
         int targetId = fetchQuery.targetId;
     AskObject[] result=new AskObject[1];
         try {
             KdTreeNode<float, int>[] objects = KDTree.RadialSearch(centerPoint,4*maxRadius,100);
             for (int i=0;i<objects.Length;i++)
             {
                 if(targetId==(idMap[objects[i].Value]).targetId)
                 {
                     result[0]=idMap[objects[i].Value];
                     break;
                 }
             }
         }
         catch (Exception e) {
             Console.WriteLine (e.StackTrace);
         }
         return  result;
 }