public int getAllele(int index){
		int allele = 0;
		
		int firstBitIndex = index*environment.bitsPerAllele;
		
		int bitsToGo = environment.bitsPerAllele;
		
		int byteIndexInGene = firstBitIndex/Byte.SIZE;
		int inBitsFromRight = Byte.SIZE-firstBitIndex%Byte.SIZE;
		
		allele |= geneData[byteIndexInGene];
		
		//remove heading bits
		
		allele &= (int)(Math.pow(2, inBitsFromRight))-1;
		
		bitsToGo -= inBitsFromRight;
		
		byte nextByte = 0;
		
		while(bitsToGo > 0){
			
			byteIndexInGene++;
			nextByte = geneData[byteIndexInGene];
			
			if(bitsToGo > Byte.SIZE){
				allele <<=  Byte.SIZE;
			} else {
				allele <<= bitsToGo;
				nextByte >>>= Byte.SIZE-bitsToGo;
			}
			
			allele |= (nextByte & 0xff);
			
			bitsToGo -= Byte.SIZE;
		}
		
		return allele;
		
	}