fully functional maze code