private String replaceLogs(String calculation) {
        Matcher matcher = Pattern.compile("log (\\d+(\\.\\d+)?)").matcher(calculation);
        StringBuffer out = new StringBuffer();
        while (matcher.find()) {
            double num = Double.parseDouble(matcher.group(1));
            matcher.appendReplacement(out, Double.toString(Math.log10(num)));
        }
        return matcher.appendTail(out).toString();
    }