s = point (null on start) f = point (null on start) for(x = 0; x < maze.width; x++){ for(y = 0; y < maze.height; y++){ if(maze.cells[x][y] == 's'){ s = (x,y); } else if( maze.cells[x][y] == 'f') { f = (x,y) } if(s != null && f != null) break; } if(s != null && f != null) break; }