public static String removePar(String expr){
		//check to see if it starts and ends with parentheses
		if((expr.length() >= 1) && expr.charAt(0) == '(' && expr.charAt(expr.length()-1) == ')'){

			int parDepth = 1; //how deep we are into parentheses nesting
			boolean parDepthReached0 = false;//if parDepth ever reaches 0 we're outside all parentheses
			//check to see if the entire expr is enclosed with parentheses
			for (int i = 1; i < expr.length() - 1; i++){
				if(expr.charAt(i) == '('){
					parDepth++;
				}
				else if(expr.charAt(i) == ')'){
					parDepth--;
				}
				if (parDepth == 0){
					parDepthReached0 = true;
				}
			}

			if(!parDepthReached0){
				return expr.substring(1, expr.length()-1);
			}
			else{
				return expr;
			}
		}
		else{
			return expr;
		}
	}