private void helper(char[][] board, int i, int j) {

    if (board[i][j] == 'O') {
      ArrayList<Pair> queue = new ArrayList<Pair>();
      queue.add(new Pair(i, j));
      while (!queue.isEmpty()) {
        // System.out.println(queue);
        Pair curtPair = queue.remove(0);
        int curtI = curtPair.i;
        int curtJ = curtPair.j;
        // one thing to notice is the place we put the boarder checker
        // if we put this checker around each of the add method below
        // will cause TLE
        // also the code will look ugly
        // it's art!
        if (curtI < 0 || curtJ < 0 || curtI >= board.length || curtJ >= board[0].length || board[curtI][curtJ] != 'O') {
          continue;
        }
        board[curtI][curtJ] = 'P';
        queue.add(new Pair(curtI - 1, curtJ));
        queue.add(new Pair(curtI + 1, curtJ));
        queue.add(new Pair(curtI, curtJ - 1));
        queue.add(new Pair(curtI, curtJ + 1));
      }
    }
  }