Rat In a Maze(Rightmost solution)

my code got accepted but i had one doubt that

//check the right cell before going
if (j + 1 <= n && maze[i][j + 1] != 'X') {

	bool rightSuccess = solve_Rat_In_A_Maze(maze, soln, i, j + 1, m, n);
	if (rightSuccess) {
		return true;
	}

}

//check the down colmn before going
if (i + 1 <= m && maze[i + 1][j] != 'X') {

	bool downSuccess = solve_Rat_In_A_Maze(maze, soln, i + 1, j, m, n);
	if (downSuccess) {
		return true;
	}
}

why we need to check before going right or down in the video sir did not checked before going right or down

if the array goes out of bound it is a runtime error so u need to check for a valid position before moving right or left
and also if that cell is not blocked, and if not blocked, will it be possible to solve it by taking that step
these three things have to be considered
if not possible so u backtrack otherwise u found a path

but we are checking for the current cell with this current code.

    if (i > m || j > n) {
	return false;
}

if (maze[i][j] == 'X') {
	return false;
}

and whenever we solve a question using recursion we assume that path from this cell exists and we move forward but in this case we are checking current cell and then also we are checking the cell where we are moving.

for printing all solutions the code is


here we are only checking once why?? here also we should check before calling rightSuccess and downSuccess.

@seemantanishth i did not understood the case for printing all solutions why we are not checking before we call rightSuccess and downSuccess there we are just simply calling but for printing one solution we are checking and getting RTE.