Please check my code? XBee

Hi there,
I would appreciate if somebody could look over my code and see if there are any errors.
This is the initial code that I have for my PIR connected to an XBee.
Whenever I see it on the XCTU I see ''?'' instead of ''E''.

#include <SoftwareSerial.h>    //  communicate with XBee
SoftwareSerial XBee(2, 3);     //TX = pin 2
                               //RX = pin 3
int inputPin = 4; // PIR sensor
int ledPin   = 13; 
int pirState = LOW; // assuming no motion detected
int val = 0; // variable for reading the pin status


void setup() 
{
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
  XBee.begin(9600);
  Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) { //turn on PIR
Serial.println("E"); // print on the output change, not state
XBee.write(Serial.read());

pirState = HIGH;
  }
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){ // we have just turned of


pirState = LOW;
}
}
}

Thanks so much