private void processStatement() {
        try {
            log.info("Statement is " + usersStatement);
            // Calculating statement
            double result = answerSearcher.getAnswer(usersStatement, new Calculator(), new Operations(), cache);
            log.debug("Sending answer to the output stream.");
            // Formatting the answer
            DecimalFormat doubleFormat = new DecimalFormat(DECIMAL_FORMAT_PATTERN);
            String answer = doubleFormat.format(result);
            os.write(answer.getBytes());
            if (log.isInfoEnabled()) {
                log.info("Result is " + answer);
            }
        } catch (IOException e) {
            log.error("Error in writing to output stream.");
        } catch (StatementErrorException e) {
            try {
                log.info("Statement error.");
                os.write(InterfaceMessages.STATEMENT_ERROR.toString().getBytes());
                ServerUserInterface.sendMessageToConsole(InterfaceMessages.STATEMENT_ERROR.toString(), true);
            } catch (IOException e1) {
                log.error("Error in writing to output stream.");
            }
        } catch (DivisionByZeroInDoubleException e) {
            log.info("Division by zero.");
            try {
                os.write(InterfaceMessages.DIVISION_BY_ZERO_EXCEPTION_ANSWER.toString().getBytes());
                ServerUserInterface.sendMessageToConsole(InterfaceMessages.DIVISION_BY_ZERO_EXCEPTION_ANSWER.toString() + e, true);
            } catch (IOException e1) {
                log.error("Error in writing to output stream.");
            }
        }finally {
            // saving cache and closing streams
            connectionsCounter.disconnect();
            try {
                log.debug("Closing output stream.");
                os.close();
                log.debug("Output stream closed successfully.");
            } catch (IOException e) {
                log.error("Error in closing output stream.", e);
            }
        }
    }