public int getRarestPiece(Peer peer){
		updatePiecePrevalence();		
		int min = Integer.MAX_VALUE;
		
		for(int i = 0; i < this.piecePrevalence.length; i++){
			if(this.ourBitfield[i] == false && peer.bitfield[i] == true){
				if(min > this.piecePrevalence[i]){
					min = piecePrevalence[i];
				}
			}
		}	
		
		if(min == Integer.MAX_VALUE){
			return -1;
		}
		
		ArrayList<Integer> indices = new ArrayList<Integer>();
		
		for(int i = 0; i < this.piecePrevalence.length; i++){
			if(this.ourBitfield[i] == false && peer.bitfield[i] == true){
				if(min == this.piecePrevalence[i]){
					indices.add(i);
				}
			}
		}
		
		Random random = new Random();
		int n = random.nextInt(indices.size());
		
		return indices.get(n);
		
	}