now makes sure the column/row is in the correct order (the middle term is in the middle); may have produced other bugs