private MoveInfo engine_control_code(GameState position) {
    // Start the time control thread
    thread_position = position;
    Thread engine_control_thread = new Thread(this);
    engine_control_thread.start();

    // Sit here until time is expired
    engine_search_completed = false; // mate score
    thread_mi = null; // best move found
    current_search_depth = -1;

    while ((!time_control.isTimeExpired(current_best_score,
      current_search_depth)
      && !engine_search_completed) || (thread_mi == null)
      ) {
      try {
        Thread.sleep(100);
      } catch (Exception e) {}
    }

    LogFile.message("Time Expired");

    abort_search(); // Kills the engine thread call both!

    // Dump out some search stats
    LogFile.message(getStats());

    // Wait for engine thread to close
    long start_time = System.currentTimeMillis();
    while (!engine_search_completed) {
      try {
        Thread.sleep(100);
      } catch (Exception e) {}
    }
    long wait_time = System.currentTimeMillis() - start_time;
    LogFile.message("Wait Time: " + wait_time);

    return thread_mi;

  }