fix maze logic