almost done for maze function