recursive function of the maze generator