public int uncompress(InputStream in, OutputStream out) throws IOException { 
        
        try {
        	BitInputStream bis = new BitInputStream(in); //compressed file
        	BitOutputStream bos = new BitOutputStream(out);
        	
	    	int bitMagic = bis.readBits(IHuffConstants.BITS_PER_INT);
	    	if(bitMagic == IHuffConstants.MAGIC_NUMBER) {	    	
	    		int bitHeader = bis.readBits(IHuffConstants.BITS_PER_INT);
	    		
	    		//IF STANDARD COUNT FORMAT
	    		if(bitHeader == IHuffConstants.STORE_COUNTS) {	    			
	            	PriorityQueue<TreeNode> q = new PriorityQueue<TreeNode>(in, bis, false);
	            	ArrayList<TreeNode> arr = q.arr(); //get array of frequencies
	    	        
	    	    	for(TreeNode tn: arr){ //add freq's from array to priority queue
	    	    		q.add(tn);			
	    			}	
	    	    	
	    	    	HuffTree temp = new HuffTree();
	    	    	huffTree = temp.createHuffTree(q); //huffman tree
	    	    	m = temp.travelTree(huffTree); //creates map 
	    	    	
	    	    	bis = q.getBitInputStream();
	    	    	
	    	    	Uncompress u = new Uncompress(huffTree);
	    	    	u.uncompressSCF(bis, bos);	
	    	    	
	    	    	showString("DECOMPRESSING: Codes for values in file: \n");
	    	    	
	    	    	for(int i : m.keySet()) {
	    	    		if(i != 256)
	    	    			showString(i + "\t" + m.get(i) + "\t\t" + (char) i);
	    	    	}
	    	    	
	    	    	showString("Bits Written: " + u.getBitsWritten());
	    	    	return u.getBitsWritten();
	    		}	   			
	    		
	    		
	    		//IF STANDARD TREE FORMAT
	    		if(bitHeader == IHuffConstants.STORE_TREE) {
	    			Uncompress u = new Uncompress(huffTree);
	    	    	u.uncompressSTF(bis, bos);
	    	    	
	    	    	showString("DECOMPRESSING: Codes for values in file: \n");
	    	    	
	    	    	HashMap<Integer, String> STFmap = u.getMap();
	    	    	for(int i : STFmap.keySet()) {
	    	    		if(i != 256)
	    	    			showString(i + "\t" + STFmap.get(i) + "\t\t" + (char) i);
	    	    	}
	    	    	
	    	    	showString("Bits Written: " + u.getBitsWritten());
	    	    	return u.getBitsWritten();
	    		}
	    		bis.close();
	    	} //end of if magic num
        } //end of try
        
        catch(Exception e) {
        	e.printStackTrace(); //debugging, print stack trace
        	throw new IOException("uncompress not implemented");
        }
        
        return 0; 
    }