XBee Series 2 communications with Arduinos

Hello,

Ive configured two Xbee series 2 and have used xctu to connect them and works fine. Then I connected one to an explorer and another to an Arduino Uno and was able to send data from the arduino to the xbee.

Now I'm trying to communicate between an Uno and Mega but I either receive nothing or -1. I have the Xbees connected with shields to the arduinos.

Xbee shields
http://www.alibaba.com/product-detail/XBee-Zigbee-Shield-RF-module-wireless_1951484048.html
http://www.tinyosshop.com/index.php?route=product/product&product_id=681

//Transmit code

int potPin = 0;

void setup() {
// Serial port enable
Serial.begin(9600);

}

void loop() {

// remap values from the analogValue5 variable to 0 / 255
int val = map(analogRead(potPin), 0, 1023, 0, 9);
//int val_dig = map(digitalRead(12), 0, 1023,0,9);
// send the value to the serial port
Serial.print(val);
//Serial.println(val_dig);
delay(1000);

}

//Receive Code

#include <Servo.h>

int servoPin = 9;

Servo myservo;

void setup() {

Serial.begin(9600);

myservo.attach(servoPin);

}

void loop() {

while(Serial.available()>0){

int data = Serial.read();
int pos = map(data, 0, 9, 0, 180);
pos = constrain(pos, 0, 180);

myservo.write(pos);

Serial.flush();
}
}

All the help would be appreciated