public Reservation modifyReservation(int reservationId, double startTime, 
     		int duration, int numPE) {
     	
     	Reservation currReservation = getReservation(reservationId);
     	if(currReservation == null) {
     		logger.info("Error modifying reservation, ID is invalid");
         	return null;
     	}

     	int resId = currReservation.getResourceID();
     	
     	// check all the values first
         boolean success = validateValue(startTime, duration, numPE);
         if (!success) {
             return null;
         }

         Reservation newReservation = currReservation.clone();
         try {
 	        newReservation.setStartTime(startTime);
 	        newReservation.setDurationTime(duration);
 	        newReservation.setNumPE(numPE);
 	        
 	        // creates the message to be sent to the grid resource
 	    	ReservationMessage message = new ReservationMessage(super.get_id(), resId, newReservation);
 	    	message.setMessageType(MessageType.MODIFY);
 	    	
 	    	// sends the message gets the reply from the grid resource
 	    	ReservationMessage reply = sendReservationMessage(message);
 	    	
 	    	// If error code is NO_ERROR, the reservation has been successful. 
 	        ErrorType error = reply.getErrorCode();
 	        if(error == ErrorType.NO_ERROR) {
 	        	reservations_.remove(newReservation.getID());
 	        	reservations_.put(newReservation.getID(), newReservation);
 	        	return newReservation;
 	        }
 	        else {
 	        	logger.info("Error modifying reservation.");
 	        }
         }
         
         catch (Exception ex) {
        	 logger.log(Level.WARNING,"Error modifying reservation.", ex);
         }
     	
     	return null;
     }