Added a loop to check if board position is filled.