public int getPeerPieceIndex(int peerID)
	{
		showBitMap();
		byte[] myFileBitMap = this.peerIDtoPiece.get(myPeerID);
		int desiredPieceID = -1;        
		//check the first available piece which is not requested, if found add to requested piece list
		byte[] peerBitMap = this.peerIDtoPiece.get(peerID);
		final int len = myFileBitMap.length;
		List<Integer> possiblePieces = new ArrayList<Integer>();
		
		for(int i = 0; i < len; i++)
		{
			if((0xFF&(int)(myFileBitMap[i] | peerBitMap[i])) > (0xFF&(int)myFileBitMap[i]))
			{
				for(int j = 0; j < 8; j++)
				{
					//if peer has the piece and I don't have it, request it
					if((myFileBitMap[i] & (1 << j)) == 0 && (peerBitMap[i] & (1 << j)) != 0)
					{
						int attemptedPieceIndex = i*8 + j;
						desiredPieceID = findAndLogRequestedPiece(attemptedPieceIndex);
						if (desiredPieceID != -1)
							possiblePieces.add(desiredPieceID);
					}
				}
			}
		}
		if (possiblePieces.size() != 0)
		{
			// generate a random number 0 and size of possiblePieces
			Random rand = new Random();
			int idx = rand.nextInt(possiblePieces.size());
			
			// access that element from the possiblePieces list and return
			int pieceIndex = possiblePieces.get(idx);
			this.piecesAskedfor.add(pieceIndex);
			return pieceIndex;
		}
		return -1;
	}