time to rework the maze function