<s>[INST] After writing the code for a Tic-Tac-Toe game, the programmer found that the game continues to allow moves after one player has won. The problem is that the code only checks for a win after all possible moves have been made on the board. However, this is inefficient and doesn't follow the rules of Tic-Tac-Toe.

The correct implementation should check for a win after each move, and end the game immediately after a player has won. Here is a function that checks if there's a win after a move:

```python
def check_win(board, player):
    # check rows
    for row in board:
        if row.count(player) == 3:
            return True
    # check columns
    for col in range(3):
        if board[0][col] == player and board[1][col] == player and board[2][col] == player:
            return True
    # check diagonals
    if (board[0][0] == player and board[1][1] == player and board[2][2] == player) or \
       (board[0][2] == player and board[1][1] == player and board[2][0] == player):
        return True
    return False
```

Implement the correct version of the game loop.

```python
def play_game():
    board = [[' ' for _ in range(3)] for _ in range(3)]
    current_player = 'X'

    # Game loop
    while True:
        # Print the current state of the board
        print_board(board)

        # Get the move from the current player
        move = get_move(current_player)
        
        # Make the move
        board[move[0]][move[1]] = current_player
        
        # Check if there's a win
        if check_win(board, current_player):
            print_board(board)
            print("Player", current_player, "wins!")
            break

        # Switch the current player
        current_player = 'O' if current_player == 'X' else 'X'

def print_board(board):
    for row in board:
        print(' | '.join(row))
        print("---------")

def get_move(player):
    while True:
        move = input("Players {}, enter your move (row and col number, space separated): ".format(player))
        try:
            move = list(map(int, move.split()))
            if move[0] < 1 or move[0] > 3 or move[1] < 1 or move[1] > 3:
                print("Invalid move, try again.")
            elif board[move[0] - 1][move[1] - 1] != ' ':
                print("That space is already occupied, try again.")
            else:
                return move
        except ValueError:
            print("Invalid move, try again.")

play_game()
```

Please complete the function `get_move(player)` and `print_board(board)` as provided above.

However, I was not able to call the `board` variable from `get_move(player)` function. How can I call a variable from a function?[/INST]