public double funct(double x[]) {
        //RefreshDataHandles();
        for (int j = 0; j < parameters.length; j++) {
            try {
                parameters[j] = x[j];
            } catch (Exception e) {
                throw new RuntimeException("Error! Parameter No. " + j + " wasn^t found" + e.toString());
            }
        }
        // singleRun();

        double value = effValue;
        //sometimes its a bad idea to calculate with NaN or Infty
        double bigNumber = 10000000;

        effValue = Math.max(effValue, -bigNumber);
        effValue = Math.min(effValue, bigNumber);

        if (Double.isNaN(effValue)) {
            effValue = -bigNumber;
        }

        currentSampleCount++;

        switch (mode) {
            case Statistics.MINIMIZATION:
                return value;
            case Statistics.MAXIMIZATION:
                return -value;
            case Statistics.ABSMINIMIZATION:
                return Math.abs(value);
            case Statistics.ABSMAXIMIZATION:
                return -Math.abs(value);
            default:
                return 0.0;
        }
    }