fix bugs for max suport > n/2