pset3 move: won't move tiles in the same row

So I have reviewed similar questions on here but can't quit fix my move code. It will correctly move tiles from within one column to row below (say 3 in the initial position for a 3x3 board). But it misfires when attempting to move across columns within the same row (say moving the the "2" to over in the initial position. I did look to see if it access outside of the array and it doesn't seem like it should. Ill post both the outputted table when I try to move the 2 plus my move code. Thank you!

8       7       6
5       4       3
1       _
2
Tile to move:

and now the code:

void draw(void)
{

for(int i=0; i<d; i++)
{   for(int j=0; j<d; j++)
if (board[i][j]==0)
{  printf(" _");
printf("\n");}

else
{printf("%2d\t", board[i][j]);
if (j==(d-1))
{printf("\n");}
}
}
}

bool move(int tile)
{
for (int i=0; i<d; i++)
{
for(int j=0; j<d; j++)
{
if (board[i][j]==tile)
{
if (i>0 && board[i-1][j]==0)
{
int swap=board[i][j];
board[i][j]=0;
board[i-1][j]=swap;
return true;
}
else if  (j>0 && board[i][j-1]==0)
{
int swap=board[i][j];
board[i][j]=0;
board [i][j-1]=swap;
return true;
}
else if (j<(d-1) && board[i][j+1]==0)
{
int swap=board[i][j];
board[i][j]=0;
board [i][j+1]=swap;
return true;
}
else if (i<(d-1) && board[i+1][j]==0)
{
int swap=board[i][j];
board[i][j]=0;
board[i+1][j]=swap;
return true;
}
}
}
}
return false;
}