# pset3 move uses the wrong Blankspace value

Hello in my move function for fifteen, when it searches for an adjacent blank space, if the tile is on the edge and the "missing" adjacent spot happens to be before my correct spot in the code, it use the value of the missing spot. and i print this: Tile to move: 1 8 7 6 _ 4 3 _ 2 1 if my blank space is in board[i][j+1], it will also read the zero in board[i+1][j], and if the wrong spot is first in the program, it will use that value and use the wrong value. here is my code. I'm having trouble figuring out what is making the program grab the wrong value first.

``````bool move(int tile)
{
int temp;
int blankspace = 0;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (board[i][j] == tile)
{
if (board[i][j+1] == blankspace)
{
temp = tile;
board[i][j] = blankspace;
board[i][j+1] = temp;
return true;
}
if(board[i+1][j] == blankspace)
{
temp = tile;
board[i][j] = blankspace;
board[i+1][j] = temp;
return true;
}
if (board[i-1][j] == blankspace)
{
temp = tile;
board[i][j] = blankspace;
board[i-1][j] = temp;
return true;
}
if (board[i][j-1] == blankspace)
{
temp = tile;
board[i][j] = blankspace;
board[i][j-1] = temp;
return true;
}

}
}
}
return false;
}
``````