public <T> T unmarshal(int type) throws JAXBException  {
		if (type == CLIENT || type == ADMIN) {
			String str = new String(buf.array());
			str = str.replace("xmlns=\"jabber:client\"", "");
			str = str.replace("xmlns='jabber:client'", "");
			if(!str.contains("xmlns='jabber:server'") && !str.contains("xmlns=\"jabber:server\"")){
				int i = 0;
				while(str.charAt(i) == ' ') {
					i++;
				}
				while(str.charAt(i) != ' ') {
					i++;
				}
				String newStr = str.substring(0, i) + " xmlns='jabber:server'" + str.substring(i);
				buf = ByteBuffer.allocate(newStr.getBytes().length).put(newStr.getBytes());
			}
		}
		ByteArrayInputStream bais = new ByteArrayInputStream(buf.array());
		Unmarshaller um = context.createUnmarshaller();
		@SuppressWarnings("unchecked")
		T xmppMessage = (T) um.unmarshal(bais);
		return xmppMessage;
	}