private CalcState work(CalcState state) {

        CalcState bestState = state;

        for (int point2 = state.point1 + 1; point2 < conf.numPoints; point2++) {
            Point p2 = new Point(Main.xFromPoint(point2), Main.yFromPoint(point2));

            StringBuilder s = new StringBuilder();
            s.append(Main.now());
            s.append(String.format("Worker %d ", workerNumber));
            s.append(String.format("starting point (%9s,%9s) ", state.p1, p2));
            s.append(String.format("of triangle %d", state.triangleNumber));
            System.out.println(s);

            for (int point3 = point2 + 1; point3 < conf.numPoints; point3++) {
                Point p3 = new Point(Main.xFromPoint(point3), Main.yFromPoint(point3));
                
                int det = (p2.y-p3.y) * (state.p1.x-p3.x) - (p3.x-p2.x) * (p3.y-state.p1.y);
                if (det == 0) {
                    continue;
                }

                CalcState tempState = testPoints(state, p2, p3);

                if (tempState.bestDist < bestState.bestDist) {
                    bestState = tempState;
                }

            }
        }
        if (bestState.bestDist < state.bestDist) {
            return bestState;
        } else {
            return new CalcState(null, Double.POSITIVE_INFINITY, state.triangleNumber, state.point1, state.p1, Double.POSITIVE_INFINITY, null);
        }
    }