private static Double doOperation(HashMap<String, Double> elements, 
			ArrayList<String> tokens, int index,String token)
	{
		double a = evaluateToken(elements,tokens,index-1),
			   b = evaluateToken(elements,tokens,index+1);
		
		Double result = null;
		
		switch(token)
		{
			case "^":
			{
				result = Math.pow(a, b);
				break;
			}
			case "*":
			{
				result =  a * b;
				break;
			}
			case "/":
			{
				result =  a / b;
				break;
			}
			case "+":
			{
				result =  a + b;
				break;
			}
			case "-":
			{
				result =  a - b;
				break;
			}
			default:
			{
				System.out.println("error");
				System.exit(0);
			}
		}
		
		replace(tokens,index,result);
		
		return result;
	}