Well, i don't know but it would be occuring here
if (board[i][j] == board[i][j + 1] most probably.