added M row seating algorithm